Skip to content

Commit ce48ed6

Browse files
Fix #4524: Add test cases for host models (#4525)
* add test cases for host models * Format test_models.py --------- Co-authored-by: Rishabh Jain <[email protected]>
1 parent 70966ba commit ce48ed6

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

tests/unit/hosts/test_models.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,43 @@ def test__str__(self):
4242
"{}: {}".format(team_name, created_by),
4343
self.challenge_host_team.__str__(),
4444
)
45+
46+
def test_get_all_challenge_host_email(self):
47+
first_user = User.objects.create(
48+
username="user1", email="[email protected]", password="password"
49+
)
50+
second_user = User.objects.create(
51+
username="user2", email="[email protected]", password="password"
52+
)
53+
ChallengeHost.objects.create(
54+
user=first_user,
55+
team_name=self.challenge_host_team,
56+
status=ChallengeHost.ACCEPTED,
57+
permissions=ChallengeHost.READ,
58+
)
59+
ChallengeHost.objects.create(
60+
user=second_user,
61+
team_name=self.challenge_host_team,
62+
status=ChallengeHost.PENDING,
63+
permissions=ChallengeHost.WRITE,
64+
)
65+
66+
other_team = ChallengeHostTeam.objects.create(
67+
team_name="Other Team", created_by=self.user
68+
)
69+
other_user = User.objects.create(
70+
username="other", email="[email protected]", password="password"
71+
)
72+
ChallengeHost.objects.create(
73+
user=other_user,
74+
team_name=other_team,
75+
status=ChallengeHost.ACCEPTED,
76+
permissions=ChallengeHost.ADMIN,
77+
)
78+
emails = self.challenge_host_team.get_all_challenge_host_email()
79+
self.assertEqual(len(emails), 3)
80+
self.assertIn("[email protected]", emails)
81+
self.assertIn("[email protected]", emails)
82+
self.assertIn("[email protected]", emails)
83+
self.assertNotIn("[email protected]", emails)
84+
self.assertIsInstance(emails, list)

0 commit comments

Comments
 (0)