diff --git a/hc/accounts/tests/test_check_token.py b/hc/accounts/tests/test_check_token.py index 9fab1860..19725b9a 100644 --- a/hc/accounts/tests/test_check_token.py +++ b/hc/accounts/tests/test_check_token.py @@ -1,5 +1,4 @@ from django.contrib.auth.models import User -from django.core.urlresolvers import reverse from django.test import TestCase @@ -14,7 +13,7 @@ class CheckTokenTestCase(TestCase): def test_it_redirects(self): r = self.client.get("/accounts/check_token/alice/secret-token/") - assert r.status_code == 302 + self.assertRedirects(r, "/checks/") # After login, password should be unusable self.alice.refresh_from_db() @@ -26,11 +25,11 @@ class CheckTokenTestCase(TestCase): # Login again, when already authenticated r = self.client.get("/accounts/check_token/alice/secret-token/") - assert r.status_code == 302 + self.assertRedirects(r, "/checks/") def test_it_redirects_bad_login(self): # Login with a bad token - r = self.client.get("/accounts/check_token/alice/invalid-token/") - assert r.status_code == 302 - assert r.url.endswith(reverse("hc-login")) - assert self.client.session["bad_link"] + url = "/accounts/check_token/alice/invalid-token/" + r = self.client.get(url, follow=True) + self.assertRedirects(r, "/accounts/login/") + self.assertContains(r, "incorrect or expired") diff --git a/hc/front/tests/test_add_channel.py b/hc/front/tests/test_add_channel.py index 3d194cde..04e07cf3 100644 --- a/hc/front/tests/test_add_channel.py +++ b/hc/front/tests/test_add_channel.py @@ -21,7 +21,7 @@ class AddChannelTestCase(TestCase): self.client.login(username="alice", password="password") r = self.client.post(url, form) - assert r.status_code == 302 + self.assertRedirects(r, "/integrations/") assert Channel.objects.count() == 1 def test_it_trims_whitespace(self): diff --git a/hc/front/tests/test_add_check.py b/hc/front/tests/test_add_check.py index 81c8e188..9f403f39 100644 --- a/hc/front/tests/test_add_check.py +++ b/hc/front/tests/test_add_check.py @@ -14,5 +14,5 @@ class AddCheckTestCase(TestCase): url = "/checks/add/" self.client.login(username="alice", password="password") r = self.client.post(url) - assert r.status_code == 302 + self.assertRedirects(r, "/checks/") assert Check.objects.count() == 1 diff --git a/hc/front/tests/test_remove_channel.py b/hc/front/tests/test_remove_channel.py index 524f1287..fe6412ff 100644 --- a/hc/front/tests/test_remove_channel.py +++ b/hc/front/tests/test_remove_channel.py @@ -19,7 +19,7 @@ class RemoveChannelTestCase(TestCase): self.client.login(username="alice", password="password") r = self.client.post(url) - assert r.status_code == 302 + self.assertRedirects(r, "/integrations/") assert Channel.objects.count() == 0 diff --git a/hc/front/tests/test_remove_check.py b/hc/front/tests/test_remove_check.py index 73b0f5d1..94a99f08 100644 --- a/hc/front/tests/test_remove_check.py +++ b/hc/front/tests/test_remove_check.py @@ -18,7 +18,7 @@ class RemoveCheckTestCase(TestCase): self.client.login(username="alice", password="password") r = self.client.post(url) - assert r.status_code == 302 + self.assertRedirects(r, "/checks/") assert Check.objects.count() == 0 diff --git a/hc/front/tests/test_update_channel.py b/hc/front/tests/test_update_channel.py index 40bfa01c..f9aea7fb 100644 --- a/hc/front/tests/test_update_channel.py +++ b/hc/front/tests/test_update_channel.py @@ -25,7 +25,7 @@ class UpdateChannelTestCase(TestCase): self.client.login(username="alice", password="password") r = self.client.post("/integrations/", data=payload) - assert r.status_code == 302 + self.assertRedirects(r, "/integrations/") channel = Channel.objects.get(code=self.channel.code) checks = channel.checks.all() diff --git a/hc/front/tests/test_update_name.py b/hc/front/tests/test_update_name.py index 3781fe4e..51222b03 100644 --- a/hc/front/tests/test_update_name.py +++ b/hc/front/tests/test_update_name.py @@ -19,7 +19,7 @@ class UpdateNameTestCase(TestCase): self.client.login(username="alice", password="password") r = self.client.post(url, data=payload) - assert r.status_code == 302 + self.assertRedirects(r, "/checks/") check = Check.objects.get(code=self.check.code) assert check.name == "Alice Was Here" diff --git a/hc/front/tests/test_update_timeout.py b/hc/front/tests/test_update_timeout.py index ddf8ed23..e3d1560d 100644 --- a/hc/front/tests/test_update_timeout.py +++ b/hc/front/tests/test_update_timeout.py @@ -19,7 +19,7 @@ class UpdateTimeoutTestCase(TestCase): self.client.login(username="alice", password="password") r = self.client.post(url, data=payload) - assert r.status_code == 302 + self.assertRedirects(r, "/checks/") check = Check.objects.get(code=self.check.code) assert check.timeout.total_seconds() == 3600