From 9ee8e3ed7a815b2a0deade80c13135006268ef59 Mon Sep 17 00:00:00 2001 From: Eve Martin Date: Thu, 4 Apr 2024 13:54:19 +0000 Subject: [PATCH] fix: debug tests --- cfl_common/common/tests/utils/student.py | 7 ++----- portal/tests/test_independent_student.py | 15 +++++++-------- portal/tests/test_teacher.py | 7 +++++-- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/cfl_common/common/tests/utils/student.py b/cfl_common/common/tests/utils/student.py index 49d040c5b..500d18c25 100644 --- a/cfl_common/common/tests/utils/student.py +++ b/cfl_common/common/tests/utils/student.py @@ -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 diff --git a/portal/tests/test_independent_student.py b/portal/tests/test_independent_student.py index 062550f6a..a32a40ccf 100644 --- a/portal/tests/test_independent_student.py +++ b/portal/tests/test_independent_student.py @@ -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) @@ -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) @@ -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() @@ -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) diff --git a/portal/tests/test_teacher.py b/portal/tests/test_teacher.py index 6ccfcad19..85d8b1a68 100644 --- a/portal/tests/test_teacher.py +++ b/portal/tests/test_teacher.py @@ -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) @@ -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)