Commit a33c6325 authored by Flavio TARSETTI's avatar Flavio TARSETTI

Merge branch '558_improve_ui_email_tests' into 'django3_migration'

Refactor email test in ui to avoid hard coded URL

See merge request !384
parents ccb73abd 0785f3d6
Pipeline #43061 passed with stage
in 15 minutes and 25 seconds
......@@ -39,17 +39,24 @@ class EmailSendingTestCase(ViewTestCase):
def setUp(self):
super().setUp()
def run_email_check(self, reference_url):
def run_email_check(self, prefix):
client = Client()
response = client.post(
reverse("login"), dict(username=self.blockeduser, password=self.password)
)
# logged_in = self.client.login(username=self.blockeduser, password=self.password)
reference_url = response.wsgi_request.build_absolute_uri(
reverse("blocked_user_reactivation")
)
self.assertEqual(response.status_code, 200)
self.assertEqual(len(mail.outbox), 1)
text_lines = mail.outbox[0].body.split("\n")
self.assertEqual(text_lines[-4], reference_url)
generated_url = text_lines[-4]
self.assertTrue(prefix in generated_url)
self.assertURLEqual(generated_url, reference_url)
def test_email_for_blocked_account_login(self):
for prefix in ["", "/platform"]:
......@@ -57,6 +64,5 @@ class EmailSendingTestCase(ViewTestCase):
mail.outbox = []
with override_settings(URL_PREFIX=prefix):
reload_urlconf()
self.run_email_check(
"http://testserver" + prefix + "/blocked_user_reactivation/"
)
self.run_email_check(prefix)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment