Skip to content

Commit 82807f6

Browse files
committed
adding more tests
1 parent c833a3a commit 82807f6

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

readthedocs/core/tests/test_signals.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,35 @@
1010
@pytest.mark.django_db
1111
class TestProjectOrganizationSignal(object):
1212

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):
1536
"""
1637
Check Project or RemoteOrganization which have multiple users do not get deleted
1738
when any of the user delete his account.
1839
"""
1940

20-
obj = G(model)
41+
obj = G(model_class)
2142
user1 = G(User)
2243
user2 = G(User)
2344
obj.users.add(user1, user2)

0 commit comments

Comments
 (0)