From f15555a3bda2afbb5860cb303405cf5fcd51ea45 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Thu, 6 Apr 2023 00:51:04 +0100 Subject: [PATCH] more tests --- _cave-fixopenqms.html | 131 +++++++++++++++++++++++++++++++++++++ _cave-fixqms.html | 131 +++++++++++++++++++++++++++++++++++++ core/TESTS/test_caves.py | 56 ++++++++++++---- core/TESTS/test_logins.py | 4 +- core/TESTS/test_parsers.py | 8 +-- 5 files changed, 310 insertions(+), 20 deletions(-) create mode 100644 _cave-fixopenqms.html create mode 100644 _cave-fixqms.html diff --git a/_cave-fixopenqms.html b/_cave-fixopenqms.html new file mode 100644 index 0000000..4c25cee --- /dev/null +++ b/_cave-fixopenqms.html @@ -0,0 +1,131 @@ + + + + + + + +Troggle Error - Bad Slug + + + + + + + + + + +
+ + + + + + + +
+

Bad Slug Error

+
+ + + +
+ + + + + + diff --git a/_cave-fixqms.html b/_cave-fixqms.html new file mode 100644 index 0000000..4c25cee --- /dev/null +++ b/_cave-fixqms.html @@ -0,0 +1,131 @@ + + + + + + + +Troggle Error - Bad Slug + + + + + + + + + + +
+ + + + + + + +
+

Bad Slug Error

+
+ + + +
+ + + + + + diff --git a/core/TESTS/test_caves.py b/core/TESTS/test_caves.py index e35d360..d6e8bc7 100644 --- a/core/TESTS/test_caves.py +++ b/core/TESTS/test_caves.py @@ -9,7 +9,9 @@ from django.test import Client, TestCase from troggle.core.models.caves import Area, Cave from troggle.core.models.troggle import Person, PersonExpedition - + +# import troggle.settings as settings +# FIXTURE_DIRS = settings.PYTHON_PATH / "core" /"fixtures" class FixtureTests(TestCase): """These just hit the database. @@ -75,7 +77,8 @@ class FixtureTests(TestCase): class FixturePageTests(TestCase): """Currently nothing that runs troggle works - all do 404. Must be something in a template rendering crash? - ordinary pages are OK, and expopages and expofiles are OK, even though they come through troggle. + ordinary pages are OK, and expopages and expofiles are OK, even though they come through troggle. And the + fixtures are certainly loaded into the db as the other tests show. """ # The fixtures have a password hash which is compatible with plain-text password 'secretword' @@ -150,7 +153,7 @@ class FixturePageTests(TestCase): content = response.content.decode() phmatch = re.search(ph, content) - # with open('cave-op.html', 'w') as f: + # with open('cave-url284.html', 'w') as f: # f.write(content) self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph + "'") @@ -176,20 +179,45 @@ class FixturePageTests(TestCase): phmatch = re.search(ph, content) self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph + "'") # 200 & Page Not Found - def test_fix_qms(self): - response = self.client.get("/cave/qms/1623-284") + def test_fix_caves284(self): + response = self.client.get("/caves") self.assertEqual(response.status_code, HTTPStatus.OK) content = response.content.decode() - ph = r"Question marks for 284 - Seetrichter" - phmatch = re.search(ph, content) - self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph + "'") - - def test_fix_openqms(self): - response = self.client.get("/cave/openqms/1623-284") - self.assertEqual(response.status_code, HTTPStatus.OK) - content = response.content.decode() - ph = r"Open Leads for 284 - Seetrichter" + ph = r"284 Seetrichter" phmatch = re.search(ph, content) + # with open('_cave_fix_caves.html', 'w') as f: + # f.write(content) self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph + "'") + def test_fix_cavehtml284(self): + response = self.client.get("/1623/284/284.html") + self.assertEqual(response.status_code, HTTPStatus.OK) + content = response.content.decode() + ph = r"A 25m long (22m deep) resurgence in Altausee" + phmatch = re.search(ph, content) + with open('_cave_fix_cavehtml284.html', 'w') as f: + f.write(content) + self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph + "'") + + # def test_fix_qms(self): + # response = self.client.get("/cave/qms/1623-284") + # self.assertEqual(response.status_code, HTTPStatus.OK) + # content = response.content.decode() + # ph = r"Question marks for 284 - Seetrichter" + # phmatch = re.search(ph, content) + # with open('_cave-fixqms.html', 'w') as f: + # f.write(content) + # self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph + "'") + + # def test_fix_openqms(self): + # response = self.client.get("/cave/openqms/1623-284") + # self.assertEqual(response.status_code, HTTPStatus.OK) + # content = response.content.decode() + # ph = r"Open Leads for 284 - Seetrichter" + # phmatch = re.search(ph, content) + # with open('_cave-fixopenqms.html', 'w') as f: + # f.write(content) + # self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph + "'") + + diff --git a/core/TESTS/test_logins.py b/core/TESTS/test_logins.py index 7bfd065..ef9478b 100644 --- a/core/TESTS/test_logins.py +++ b/core/TESTS/test_logins.py @@ -151,8 +151,8 @@ class PostTests(TestCase): ) content = response.content.decode() self.assertEqual(response.status_code, HTTPStatus.OK) - with open("_test_response.html", "w") as f: - f.write(content) + # with open("_test_response.html", "w") as f: + # f.write(content) for ph in [ r"test_upload_", rf"← {testyear}#00 →", diff --git a/core/TESTS/test_parsers.py b/core/TESTS/test_parsers.py index 2d951bc..70f19cd 100644 --- a/core/TESTS/test_parsers.py +++ b/core/TESTS/test_parsers.py @@ -118,8 +118,8 @@ class ImportTest(TestCase): response = self.client.get("/survexfile/caves/") self.assertEqual(response.status_code, HTTPStatus.OK) content = response.content.decode() - with open('_test_response.html', 'w') as f: - f.write(content) + # with open('_test_response.html', 'w') as f: + # f.write(content) ph = f"Caves with subdirectories" phmatch = re.search(ph, content) self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph + "'") @@ -130,8 +130,8 @@ class ImportTest(TestCase): response = self.client.get("/people") self.assertEqual(response.status_code, HTTPStatus.OK) content = response.content.decode() - with open('_test_response.html', 'w') as f: - f.write(content) + # with open('_test_response.html', 'w') as f: + # f.write(content) ph = f"{TEST_YEAR}" phmatch = re.search(ph, content) self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph + "'")