Fixing URLs for cave descriptions

This commit is contained in:
Philip Sargent
2022-03-18 20:00:15 +00:00
parent 6f32364675
commit 6a18511dd0
9 changed files with 110 additions and 82 deletions

View File

@@ -158,14 +158,30 @@ class PageTests(TestCase):
self.assertEqual(len(response.content), 6057)
def test_cave_kataster_not_found(self):
# database not loaded, so no caves found
response = self.client.get('/cave/115')
self.assertEqual(response.status_code, 200)
# database not loaded, so no caves found; so looks for a generic expopage and fails
response = self.client.get('/1623/115.htm')
self.assertEqual(response.status_code, 404)
content = response.content.decode()
ph = r"Cave Identifier not found in database"
ph = r"Page not found 1623/115.htm"
phmatch = re.search(ph, content)
self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph +"'")
def test_caves_page(self):
response = self.client.get('/caves')
self.assertEqual(response.status_code, 200)
content = response.content.decode()
ph = r"Cave Number Index - kept updated"
phmatch = re.search(ph, content)
self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph +"'")
def test_caves_page_kataster_not_found(self):
response = self.client.get('/caves')
self.assertEqual(response.status_code, 200)
content = response.content.decode()
ph = r"115"
phmatch = re.search(ph, content)
self.assertIsNone(phmatch, "Failed to find expected text: '" + ph +"'")
def test_page_ss(self):
response = self.client.get('/survey_scans/')
self.assertEqual(response.status_code, 200)

View File

@@ -37,7 +37,7 @@ class FixtureTests(TestCase):
def test_fix_cave_loaded115(self):
c = Cave.objects.get(kataster_number='115')
self.assertEqual(str(c.description_file), "1623/115.htm")
self.assertEqual(str(c.url), "1623/115.htm")
self.assertEqual(str(c.url), "1623/115.url") # intentional
self.assertEqual(str(c.filename), "1623-115.html")
# c.area is a 'ManyRelatedManager' object and not iterable
@@ -135,7 +135,7 @@ class FixturePageTests(TestCase):
def test_fix_cave_url115(self):
ph = self.ph
response = self.client.get('/1623/115.htm')
response = self.client.get('/1623/115.url') # yes this is intentional, see the inserted data above & fixture
self.assertEqual(response.status_code, 200)
content = response.content.decode()