Skip to content

Commit

Permalink
change union type and edit test for empty mail
Browse files Browse the repository at this point in the history
  • Loading branch information
CJGutz committed Feb 21, 2024
1 parent 9ce0f2d commit 87c3899
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions authentication/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,10 @@ def test_convert_ntnu_and_stud_emails(self):
self.assertEqual(new_emails[1], "[email protected]")

def test_convert_empty_email(self):
emails = ["", "ntnu", "@ntnu", "@ntnu.no"]
emails = ["", "ntnu", "@ntnu.", "@ntnu.no"]
new_emails = convert_to_stud_email(*emails)
self.assertEqual(new_emails, ["", "ntnu", "@stud.ntnu.no", "@stud.ntnu.no"])
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]"])
self.assertEqual(new_emails, ["f@stud.ntnu.no"])
4 changes: 2 additions & 2 deletions authentication/views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, Union
from typing import List

from django.contrib.auth import get_user_model, logout
from django.shortcuts import redirect
Expand Down Expand Up @@ -98,7 +98,7 @@ def get_user_by_stud_or_ntnu_email(email: str):
return user


def convert_to_stud_email(*user_emails: Union[str, None]) -> List[str]:
def convert_to_stud_email(*user_emails: str | None) -> List[str]:
new_emails = []
for email in user_emails:
if not email:
Expand Down

0 comments on commit 87c3899

Please sign in to comment.