Skip to content

Commit

Permalink
fix: debug tests
Browse files Browse the repository at this point in the history
  • Loading branch information
evemartin committed Apr 4, 2024
1 parent f3a1cae commit 9ee8e3e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
7 changes: 2 additions & 5 deletions cfl_common/common/tests/utils/student.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,7 @@ def create_independent_student(page, mock_send_dotdigital_email):
return page, name, username, email_address, password


def verify_email(page):
assert len(mail.outbox) > 0

page = email.follow_verify_email_link_to_login(page, mail.outbox[0], "independent")
mail.outbox = []
def verify_email(page, verification_url):
page = email.follow_verify_email_link_to_login(page, verification_url, "independent")

return page
15 changes: 7 additions & 8 deletions portal/tests/test_independent_student.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@ def test_login_success(self):
page = page.independent_student_login(username, password)
assert self.is_dashboard(page)

def test_login_not_verified(self):
@patch("common.helpers.emails.send_dotdigital_email")
def test_login_not_verified(self, mock_send_dotdigital_email):
username, password, _ = create_independent_student_directly(preverified=False)
self.selenium.get(self.live_server_url)
page = HomePage(self.selenium)
Expand All @@ -268,7 +269,9 @@ def test_login_not_verified(self):
assert page.has_login_failed("independent_student_login_form", INVALID_LOGIN_MESSAGE)
print(errors)

verify_email(page)
verification_url = mock_send_dotdigital_email.call_args.kwargs["personalization_values"]["VERIFICATION_LINK"]

verify_email(page, verification_url)

assert is_email_verified_message_showing(self.selenium)

Expand Down Expand Up @@ -374,9 +377,7 @@ def test_change_email(self, mock_send_dotdigital_email):
assert is_student_details_updated_message_showing(self.selenium)
assert is_email_updated_message_showing(self.selenium)

subject = str(mail.outbox[0].subject)
assert subject == "Email address update"
mail.outbox = []
mock_send_dotdigital_email.assert_called_once_with(1551600, ANY, personalization_values=ANY)

page = (
self.go_to_homepage()
Expand Down Expand Up @@ -404,11 +405,9 @@ def test_change_email(self, mock_send_dotdigital_email):

page = page.logout()

subject = str(mail.outbox[0].subject)
assert subject == "Email address update"
mock_send_dotdigital_email.assert_called_once_with(1551600, ANY, personalization_values=ANY)

page = email_utils.follow_change_email_link_to_independent_dashboard(page, mail.outbox[1])
mail.outbox = []

page = page.independent_student_login(new_email, password)

Expand Down
7 changes: 5 additions & 2 deletions portal/tests/test_teacher.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,8 @@ def test_login_success(self):
page = page.login(email, password)
assert self.is_dashboard_page(page)

def test_login_not_verified(self):
@patch("common.helpers.emails.send_dotdigital_email")
def test_login_not_verified(self, mock_send_dotdigital_email):
email, password = signup_teacher_directly(preverified=False)
create_organisation_directly(email)
_, _, access_code = create_class_directly(email)
Expand All @@ -486,7 +487,9 @@ def test_login_not_verified(self):

assert page.has_login_failed("form-login-teacher", INVALID_LOGIN_MESSAGE)

verify_email(page)
verification_url = mock_send_dotdigital_email.call_args.kwargs["personalization_values"]["VERIFICATION_LINK"]

verify_email(page, verification_url)

assert is_email_verified_message_showing(self.selenium)

Expand Down

0 comments on commit 9ee8e3e

Please sign in to comment.