-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #785 from hackerspace-ntnu/783-force-stud-address
783 force stud address
- Loading branch information
Showing
6 changed files
with
76 additions
and
14 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 |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
from social_django.utils import load_backend, load_strategy | ||
|
||
from authentication.apps import AuthenticationConfig | ||
from authentication.views import associate_by_email, save_profile | ||
from authentication.views import associate_by_email, convert_to_stud_email, save_profile | ||
|
||
|
||
class AuthenticationConfigTest(TestCase): | ||
|
@@ -126,3 +126,48 @@ def test_existing_user_profiles(self): | |
def test_assoc_existing_user(self): | ||
associate = associate_by_email(self.backend, {}, user=self.testuser) | ||
self.assertIsNone(associate) | ||
|
||
def test_convert_stud_emails(self): | ||
emails = [ | ||
"[email protected]", | ||
"[email protected]", | ||
] | ||
new_emails = convert_to_stud_email(*emails) | ||
|
||
self.assertEqual(emails, new_emails) | ||
|
||
def test_convert_ntnu_emails(self): | ||
emails = [ | ||
"[email protected]", | ||
"[email protected]", | ||
] | ||
|
||
new_emails = convert_to_stud_email(*emails) | ||
|
||
self.assertEqual(len(new_emails), 2) | ||
self.assertNotEqual(emails, new_emails) | ||
self.assertEqual(new_emails[0], "[email protected]") | ||
self.assertEqual(new_emails[1], "[email protected]") | ||
|
||
def test_convert_ntnu_and_stud_emails(self): | ||
emails = [ | ||
"[email protected]", | ||
"[email protected]", | ||
] | ||
|
||
new_emails = convert_to_stud_email(*emails) | ||
|
||
self.assertEqual(len(new_emails), 2) | ||
self.assertNotEqual(emails, new_emails) | ||
self.assertEqual(new_emails[0], "[email protected]") | ||
self.assertEqual(new_emails[0], emails[0]) | ||
self.assertEqual(new_emails[1], "[email protected]") | ||
|
||
def test_convert_empty_email(self): | ||
emails = ["", "ntnu", "@ntnu.", "@ntnu.no"] | ||
new_emails = convert_to_stud_email(*emails) | ||
self.assertEqual(new_emails, ["ntnu", "@stud.ntnu.no", "@stud.ntnu.no"]) | ||
|
||
def test_convert_none_values(self): | ||
new_emails = convert_to_stud_email("[email protected]", None, None) | ||
self.assertEqual(new_emails, ["[email protected]"]) |
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
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