From 9250bc9babf70b28ba971e5e9d6f0526ceaac2f0 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Tue, 12 Jun 2018 17:59:34 +0200 Subject: Fix find test --- archaeological_finds/tests.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'archaeological_finds') diff --git a/archaeological_finds/tests.py b/archaeological_finds/tests.py index a4a1ad471..c62922499 100644 --- a/archaeological_finds/tests.py +++ b/archaeological_finds/tests.py @@ -459,9 +459,8 @@ class FindTest(FindInit, TestCase): response.content) c = Client() response = c.get(reverse('show-find', kwargs={'pk': obj.pk})) - self.assertEqual(response.status_code, 200) # empty content when not allowed - self.assertEqual(response.content, "") + self.assertRedirects(response, "/") c.login(username=self.username, password=self.password) response = self.client.get(reverse('show-find', kwargs={'pk': obj.pk})) @@ -508,8 +507,8 @@ class FindSearchTest(FindInit, TestCase): # no result when no authentication response = c.get(reverse('get-find'), search) - self.assertEqual(response.status_code, 200) - self.assertTrue(not json.loads(response.content)) + self.assertRedirects(response, "/") + c.login(username=self.username, password=self.password) # one result for exact search @@ -569,8 +568,7 @@ class FindSearchTest(FindInit, TestCase): # no result when no authentication response = c.get(reverse('get-find'), search) - self.assertEqual(response.status_code, 200) - self.assertTrue(not json.loads(response.content)) + self.assertRedirects(response, "/") # one result for exact search c.login(username=self.username, password=self.password) @@ -612,8 +610,8 @@ class FindSearchTest(FindInit, TestCase): # no result when no authentication response = c.get(reverse('get-find'), search) - self.assertEqual(response.status_code, 200) - self.assertTrue(not json.loads(response.content)) + self.assertRedirects(response, "/") + c.login(username=self.username, password=self.password) # one result for exact search @@ -706,7 +704,8 @@ class FindPermissionTest(FindInit, TestCase): # no result when no authentification c = Client() response = c.get(reverse('get-find')) - self.assertTrue(not json.loads(response.content)) + self.assertTrue(not response.content or + not json.loads(response.content)) # possession c = Client() -- cgit v1.2.3