Commit 0785f3d6 authored by Samuel GAIST's avatar Samuel GAIST

[ui][test][views] Refactor the test to avoid hard coded URL

parent ccb73abd
Pipeline #43058 passed with stage
in 15 minutes and 31 seconds
...@@ -39,17 +39,24 @@ class EmailSendingTestCase(ViewTestCase): ...@@ -39,17 +39,24 @@ class EmailSendingTestCase(ViewTestCase):
def setUp(self): def setUp(self):
super().setUp() super().setUp()
def run_email_check(self, reference_url): def run_email_check(self, prefix):
client = Client() client = Client()
response = client.post( response = client.post(
reverse("login"), dict(username=self.blockeduser, password=self.password) 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(response.status_code, 200)
self.assertEqual(len(mail.outbox), 1) self.assertEqual(len(mail.outbox), 1)
text_lines = mail.outbox[0].body.split("\n") 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): def test_email_for_blocked_account_login(self):
for prefix in ["", "/platform"]: for prefix in ["", "/platform"]:
...@@ -57,6 +64,5 @@ class EmailSendingTestCase(ViewTestCase): ...@@ -57,6 +64,5 @@ class EmailSendingTestCase(ViewTestCase):
mail.outbox = [] mail.outbox = []
with override_settings(URL_PREFIX=prefix): with override_settings(URL_PREFIX=prefix):
reload_urlconf() 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