-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
308fc0b
commit 50c89db
Showing
2 changed files
with
70 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,6 +63,60 @@ def test_parent_children(self): | |
self.assertEqual(self.club2.parent_orgs.first(), self.club1) | ||
self.assertEqual(self.club1.children_orgs.first(), self.club2) | ||
|
||
def test_get_officer_emails(self): | ||
# Create test users with various email formats | ||
user1 = get_user_model().objects.create_user( | ||
"user1", "[email protected]", "password" | ||
) | ||
user2 = get_user_model().objects.create_user( | ||
"user2", " [email protected] ", "password" | ||
) # whitespace | ||
user3 = get_user_model().objects.create_user( | ||
"user3", "", "password" | ||
) # empty email | ||
user4 = get_user_model().objects.create_user( | ||
"user4", "[email protected]", "password" | ||
) | ||
|
||
# Create memberships for the test users | ||
Membership.objects.create( | ||
person=user1, club=self.club1, role=Membership.ROLE_OFFICER | ||
) | ||
Membership.objects.create( | ||
person=user2, club=self.club1, role=Membership.ROLE_OWNER | ||
) | ||
Membership.objects.create( | ||
person=user3, club=self.club1, role=Membership.ROLE_OFFICER | ||
) | ||
Membership.objects.create( | ||
person=user4, club=self.club1, role=Membership.ROLE_OFFICER, active=False | ||
) # alumni | ||
|
||
# Test with valid club email | ||
self.club1.email = "[email protected]" | ||
self.club1.save() | ||
|
||
officer_emails = self.club1.get_officer_emails() | ||
expected_emails = ["[email protected]", "[email protected]", "[email protected]"] | ||
self.assertEqual(officer_emails, expected_emails) | ||
|
||
# Ensure alumni are not included | ||
self.assertNotIn("[email protected]", officer_emails) | ||
|
||
# Test with invalid club email | ||
self.club1.email = "invalid-email" | ||
self.club1.save() | ||
|
||
officer_emails = self.club1.get_officer_emails() | ||
expected_emails = ["[email protected]", "[email protected]"] | ||
self.assertEqual(officer_emails, expected_emails) | ||
|
||
# Test with empty club email | ||
self.club1.email = "" | ||
self.club1.save() | ||
officer_emails = self.club1.get_officer_emails() | ||
self.assertEqual(officer_emails, expected_emails) | ||
|
||
|
||
class ProfileTestCase(TestCase): | ||
def test_profile_creation(self): | ||
|