File tree 1 file changed +24
-3
lines changed
1 file changed +24
-3
lines changed Original file line number Diff line number Diff line change 10
10
@pytest .mark .django_db
11
11
class TestProjectOrganizationSignal (object ):
12
12
13
- @pytest .mark .parametrize ('model' , [Project , RemoteOrganization ])
14
- def test_multiple_users_project_organization_not_delete (self , model ):
13
+ @pytest .mark .parametrize ('model_class' , [Project , RemoteOrganization ])
14
+ def test_project_organization_get_deleted_upon_user_delete (self , model_class ):
15
+ """
16
+ If the user has Project or RemoteOrganization where he is the only user,
17
+ upon deleting his account, the Project or RemoteOrganization should also get
18
+ deleted.
19
+ """
20
+
21
+ obj = G (model_class )
22
+ user1 = G (User )
23
+ obj .users .add (user1 )
24
+
25
+ obj .refresh_from_db ()
26
+ assert obj .users .all ().count () == 1
27
+
28
+ # Delete the user
29
+ user1 .delete ()
30
+ # The object should not exist
31
+ obj = model_class .objects .all ().filter (id = obj .id )
32
+ assert not obj .exists ()
33
+
34
+ @pytest .mark .parametrize ('model_class' , [Project , RemoteOrganization ])
35
+ def test_multiple_users_project_organization_not_delete (self , model_class ):
15
36
"""
16
37
Check Project or RemoteOrganization which have multiple users do not get deleted
17
38
when any of the user delete his account.
18
39
"""
19
40
20
- obj = G (model )
41
+ obj = G (model_class )
21
42
user1 = G (User )
22
43
user2 = G (User )
23
44
obj .users .add (user1 , user2 )
You can’t perform that action at this time.
0 commit comments