Skip to content

Commit

Permalink
fix: attempt to fix under 13 test
Browse files Browse the repository at this point in the history
  • Loading branch information
evemartin committed Apr 2, 2024
1 parent 3eaaecb commit 55d6029
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 21 deletions.
6 changes: 1 addition & 5 deletions cfl_common/common/mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,4 @@ def send_dotdigital_email(
timeout=timeout,
)

assert response.ok, (
"Failed to send email."
f" Reason: {response.reason}."
f" Text: {response.text}."
)
assert response.ok, "Failed to send email." f" Reason: {response.reason}." f" Text: {response.text}."
33 changes: 17 additions & 16 deletions portal/tests/test_independent_student.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from django.urls import reverse
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from unittest.mock import patch, ANY

from portal.forms.error_messages import INVALID_LOGIN_MESSAGE

Expand Down Expand Up @@ -140,24 +141,24 @@ def test_signup_invalid_name_fails(self):
def test_signup_under_13_sends_parent_email(self):
c = Client()

response = c.post(
reverse("register"),
{
"independent_student_signup-date_of_birth_day": datetime.date.today().day,
"independent_student_signup-date_of_birth_month": datetime.date.today().month,
"independent_student_signup-date_of_birth_year": datetime.date.today().year,
"independent_student_signup-name": "Young person",
"independent_student_signup-email": "[email protected]",
"independent_student_signup-consent_ticked": "on",
"independent_student_signup-password": "$RRFVBGT%6yhnmju7",
"independent_student_signup-confirm_password": "$RRFVBGT%6yhnmju7",
"g-recaptcha-response": "something",
},
)
with patch("common.mail.send_dotdigital_email") as mock_send_dotdigital_email:
response = c.post(
reverse("register"),
{
"independent_student_signup-date_of_birth_day": datetime.date.today().day,
"independent_student_signup-date_of_birth_month": datetime.date.today().month,
"independent_student_signup-date_of_birth_year": datetime.date.today().year,
"independent_student_signup-name": "Young person",
"independent_student_signup-email": "[email protected]",
"independent_student_signup-consent_ticked": "on",
"independent_student_signup-password": "$RRFVBGT%6yhnmju7",
"independent_student_signup-confirm_password": "$RRFVBGT%6yhnmju7",
"g-recaptcha-response": "something",
},
)

assert response.status_code == 302
assert len(mail.outbox) == 1
assert mail.outbox[0].subject == "Code for Life account request"
mock_send_dotdigital_email.assert_called_once_with(1551587, ANY, ANY)


# Class for Selenium tests. We plan to replace these and turn them into Cypress tests
Expand Down

0 comments on commit 55d6029

Please sign in to comment.