<s> from __future__ import absolute_import <EOL> from django . core . urlresolvers import reverse <EOL> from sentry . models import ( <EOL> Organization , OrganizationMember , OrganizationStatus , User <EOL> ) <EOL> from sentry . testutils import TestCase <EOL> class RemoveAccountTest ( TestCase ) : <EOL> def setUp ( self ) : <EOL> super ( RemoveAccountTest , self ) . setUp ( ) <EOL> other_user = self . create_user ( '<STR_LIT>' ) <EOL> self . organization = self . create_organization ( name = '<STR_LIT:a>' , owner = self . user ) <EOL> self . create_member ( <EOL> user = other_user , <EOL> organization = self . organization , <EOL> role = '<STR_LIT>' , <EOL> ) <EOL> self . organization2 = self . create_organization ( name = '<STR_LIT:b>' , owner = self . user ) <EOL> self . create_member ( <EOL> user = other_user , <EOL> organization = self . organization2 , <EOL> role = '<STR_LIT>' , <EOL> ) <EOL> self . organization3 = self . create_organization ( name = '<STR_LIT:c>' , owner = other_user ) <EOL> self . path = reverse ( '<STR_LIT>' ) <EOL> self . login_as ( self . user ) <EOL> def test_renders_with_context ( self ) : <EOL> resp = self . client . get ( self . path ) <EOL> assert resp . status_code == <NUM_LIT:200> <EOL> self . assertTemplateUsed ( resp , '<STR_LIT>' ) <EOL> assert resp . context [ '<STR_LIT>' ] == [ { <EOL> '<STR_LIT>' : self . organization , <EOL> '<STR_LIT>' : True , <EOL> } , { <EOL> '<STR_LIT>' : self . organization2 , <EOL> '<STR_LIT>' : False , <EOL> } ] <EOL> def test_implicit_delete ( self ) : <EOL> resp = self . client . post ( self . path ) <EOL> assert resp . status_code == <NUM_LIT:200> <EOL> self . assertTemplateUsed ( resp , '<STR_LIT>' ) <EOL> assert not User . objects . get ( <EOL> id = self . user . id , <EOL> ) . is_active <EOL> assert Organization . objects . get ( <EOL> id = self . organization . id , <EOL> ) . status == OrganizationStatus . PENDING_DELETION <EOL> assert Organization . objects . get ( <EOL> id = self . organization2 . id , <EOL> ) . status == OrganizationStatus . VISIBLE <EOL> assert not OrganizationMember . objects . filter ( <EOL> user = self . user , <EOL> organization = self . organization2 , <EOL> ) . exists ( ) <EOL> assert Organization . objects . get ( <EOL> id = self . organization3 . id , <EOL> ) . status == OrganizationStatus . VISIBLE <EOL> def test_explicit_delete ( self ) : <EOL> resp = self . client . post ( self . path , data = { <EOL> '<STR_LIT>' : [ self . organization . slug , self . organization2 . slug , <EOL> self . organization3 . slug ] , <EOL> } ) <EOL> assert resp . status_code == <NUM_LIT:200> <EOL> self . assertTemplateUsed ( resp , '<STR_LIT>' ) <EOL> assert Organization . objects . get ( <EOL> id = self . organization . id , <EOL> ) . status == OrganizationStatus . PENDING_DELETION <EOL> assert Organization . objects . get ( <EOL> id = self . organization2 . id , <EOL> ) . status == OrganizationStatus . PENDING_DELETION <EOL> assert Organization . objects . get ( <EOL> id = self . organization3 . id , <EOL> ) . status == OrganizationStatus . VISIBLE </s>
