diff --git a/core/TESTS/tests.py b/core/TESTS/tests.py index 8f49a40..c663df6 100644 --- a/core/TESTS/tests.py +++ b/core/TESTS/tests.py @@ -26,6 +26,7 @@ todo = """ADD TESTS when we are redirecting /expofiles/ to a remote file-deliver """ import re +from http import HTTPStatus from django.test import Client, TestCase @@ -51,7 +52,7 @@ class PageTests(TestCase): def test_expoweb_root(self): response = self.client.get("") content = response.content.decode() - self.assertEqual(response.status_code, 200) + self.assertEqual(response.status_code, HTTPStatus.OK) ph = r"CUCC in Austria" phmatch = re.search(ph, content) self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph + "'") @@ -59,14 +60,14 @@ class PageTests(TestCase): def test_expoweb_root_slash(self): response = self.client.get("/") content = response.content.decode() - self.assertEqual(response.status_code, 200) + self.assertEqual(response.status_code, HTTPStatus.OK) ph = r"CUCC in Austria" phmatch = re.search(ph, content) self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph + "'") def test_expoweb_paths(self): response = self.client.get("/pathsreport") - self.assertEqual(response.status_code, 200) + self.assertEqual(response.status_code, HTTPStatus.OK) content = response.content.decode() ph = r"This report is generated from" phmatch = re.search(ph, content) @@ -75,17 +76,17 @@ class PageTests(TestCase): def test_expoweb_dir(self): response = self.client.get("/handbook") response.content.decode() - self.assertEqual(response.status_code, 302) # directory, so redirects to /index.htm + self.assertEqual(response.status_code, HTTPStatus.FOUND) # 302 directory, so redirects to /index.htm def test_expoweb_dirslash(self): response = self.client.get("/handbook/") response.content.decode() - self.assertEqual(response.status_code, 302) # directory, so redirects to /index.htm + self.assertEqual(response.status_code, HTTPStatus.FOUND) # 302 directory, so redirects to /index.htm def test_expoweb_dir_no_index(self): response = self.client.get("/handbook/troggle") content = response.content.decode() - self.assertEqual(response.status_code, 404) + self.assertEqual(response.status_code, HTTPStatus.NOT_FOUND) ph = r"Page not found handbook/troggle/index.html" phmatch = re.search(ph, content) self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph + "'") @@ -93,7 +94,7 @@ class PageTests(TestCase): def test_expoweb_dir_with_index_htm(self): response = self.client.get("/years/1999/index.htm") content = response.content.decode() - self.assertEqual(response.status_code, 200) # directory, so redirects to /index.htm + self.assertEqual(response.status_code, HTTPStatus.OK) # directory, so redirects to /index.htm ph = r"Passage descriptions for 1999" phmatch = re.search(ph, content) self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph + "'") @@ -101,7 +102,7 @@ class PageTests(TestCase): def test_expoweb_dir_with_index_html(self): response = self.client.get("/years/2015/index.html") content = response.content.decode() - self.assertEqual(response.status_code, 200) # directory, so redirects to /index.htm + self.assertEqual(response.status_code, HTTPStatus.OK) # directory, so redirects to /index.htm ph = r"Things left at top camp 2014" phmatch = re.search(ph, content) self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph + "'") @@ -109,7 +110,7 @@ class PageTests(TestCase): def test_expoweb_dir_with_index2(self): response = self.client.get("/handbook/index.htm") content = response.content.decode() - self.assertEqual(response.status_code, 200) + self.assertEqual(response.status_code, HTTPStatus.OK) ph = r"Introduction to expo" phmatch = re.search(ph, content) # print("\n ! - test_expoweb_dir_with_index2\n{}\n{}".format(response.reason_phrase, content)) @@ -118,7 +119,7 @@ class PageTests(TestCase): def test_expoweb_htm(self): response = self.client.get("/handbook/index.htm") content = response.content.decode() - self.assertEqual(response.status_code, 200) + self.assertEqual(response.status_code, HTTPStatus.OK) ph = r"Introduction to expo" phmatch = re.search(ph, content) self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph + "'") @@ -126,7 +127,7 @@ class PageTests(TestCase): def test_expoweb_notfound(self): response = self.client.get("/handbook/_test_zyxxypqrqx.html") content = response.content.decode() - self.assertEqual(response.status_code, 404) + self.assertEqual(response.status_code, HTTPStatus.NOT_FOUND) ph = r"