diff options
Diffstat (limited to 'core/TESTS/tests.py')
-rw-r--r-- | core/TESTS/tests.py | 48 |
1 files changed, 45 insertions, 3 deletions
diff --git a/core/TESTS/tests.py b/core/TESTS/tests.py index 1cf9f60..77cd998 100644 --- a/core/TESTS/tests.py +++ b/core/TESTS/tests.py @@ -190,8 +190,22 @@ class PageTests(TestCase): content = response.content.decode() self.assertEqual(response.status_code, 302) - def test_page_expofiles_dir(self): - # Flat file tests. + def test_page_expofiles_root_dir(self): + # Root expofiles - odd interaction with url parsing so needs testing + response = self.client.get('/expofiles') + if response.status_code != 200: + self.assertEqual(response.status_code, 302) + if response.status_code != 302: + self.assertEqual(response.status_code, 200) + content = response.content.decode() + for ph in [ r'a href="/expofiles/geotiffsurveys">/geotiffsurveys/', + r'<a href="/expofiles/photos">/photos/', + r'<a href="/expofiles/surveyscans">/surveyscans/' ]: + phmatch = re.search(ph, content) + self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph +"'") + + def test_page_expofiles_root_slash_dir(self): + # Root expofiles - odd interaction with url parsing so needs testing response = self.client.get('/expofiles/') if response.status_code != 200: self.assertEqual(response.status_code, 302) @@ -200,7 +214,35 @@ class PageTests(TestCase): content = response.content.decode() for ph in [ r'a href="/expofiles/geotiffsurveys">/geotiffsurveys/', r'<a href="/expofiles/photos">/photos/', - r'<a href="/expofiles/surveyscans">/surveyscans' ]: + r'<a href="/expofiles/surveyscans">/surveyscans/' ]: + phmatch = re.search(ph, content) + self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph +"'") + + def test_page_expofiles_badness(self): + # should display expofiles directory contents not its parent + response = self.client.get('/expofiles/99badness99') + if response.status_code != 200: + self.assertEqual(response.status_code, 302) + if response.status_code != 302: + self.assertEqual(response.status_code, 200) + content = response.content.decode() + for ph in [ r'a href="/expofiles/geotiffsurveys">/geotiffsurveys/', + r'<a href="/expofiles/photos">/photos/', + r'<a href="/expofiles/surveyscans">/surveyscans/' ]: + phmatch = re.search(ph, content) + self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph +"'") + + def test_page_expofiles_docs_dir(self): + # Flat file tests. + response = self.client.get('/expofiles/documents/') + if response.status_code != 200: + self.assertEqual(response.status_code, 302) + if response.status_code != 302: + self.assertEqual(response.status_code, 200) + content = response.content.decode() + for ph in [ r'a href="/expofiles/documents/bier-tent-instructions.pdf">bier-tent-instructions.pdf', + r'a href="/expofiles/documents/boc.pdf">boc.pdf', + r'a href="/expofiles/documents/bierbook">/bierbook' ]: phmatch = re.search(ph, content) self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph +"'") |