diff --git a/core/TESTS/tests.py b/core/TESTS/tests.py
index 96d726f..7936fb0 100644
--- a/core/TESTS/tests.py
+++ b/core/TESTS/tests.py
@@ -207,24 +207,30 @@ class PageTests(TestCase):
def test_page_expofiles_dir(self):
# Flat file tests.
response = self.client.get('/expofiles/')
- self.assertEqual(response.status_code, 200)
- content = response.content.decode()
- for ph in [ r'a href="/expofiles/geotiffsurveys">/geotiffsurveys/',
- r'/photos/',
- r'/surveyscans' ]:
- phmatch = re.search(ph, content)
- self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph +"'")
+ 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'/photos/',
+ r'/surveyscans' ]:
+ phmatch = re.search(ph, content)
+ self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph +"'")
def test_page_survey_scans_dir(self):
# Flat file tests.
response = self.client.get('/expofiles/surveyscans')
- self.assertEqual(response.status_code, 200)
- content = response.content.decode()
- for ph in [ r'/2004/',
- r'/1989LUSS/',
- r'/2018' ]:
- phmatch = re.search(ph, content)
- self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph +"'")
+ 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'/2004/',
+ r'/1989LUSS/',
+ r'/2018' ]:
+ phmatch = re.search(ph, content)
+ self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph +"'")
def test_page_folk(self):
# This page is separately generated, so it has the full data content
@@ -242,20 +248,26 @@ class PageTests(TestCase):
def test_page_expofile_documents(self):
# this gets an empty page as the database has not been loaded
response = self.client.get('/expofiles/documents')
- self.assertEqual(response.status_code, 200)
- content = response.content.decode()
- ph = r'notice_generale_cordes_courant'
- phmatch = re.search(ph, content)
- self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph +"'")
+ 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()
+ ph = r'notice_generale_cordes_courant'
+ phmatch = re.search(ph, content)
+ self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph +"'")
def test_page_expofile_documents_slash(self):
# this gets an empty page as the database has not been loaded
response = self.client.get('/expofiles/documents/')
- self.assertEqual(response.status_code, 200)
- content = response.content.decode()
- ph = r'notice_generale_cordes_courant'
- phmatch = re.search(ph, content)
- self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph +"'")
+ 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()
+ ph = r'notice_generale_cordes_courant'
+ phmatch = re.search(ph, content)
+ self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph +"'")
@@ -294,6 +306,42 @@ class PageTests(TestCase):
if response.status_code != 302:
self.assertEqual(response.status_code, 200)
self.assertEqual(len(response.content), 12915413)
+
+ def test_page_site_media_ok(self):
+ # Flat file tests.
+ response = self.client.get('/site_media/surveyHover.gif')
+ if response.status_code != 200:
+ self.assertEqual(response.status_code, 302)
+ if response.status_code != 302:
+ self.assertEqual(response.status_code, 200)
+ self.assertEqual(len(response.content), 39482 )
+
+ def test_page_photos_ok(self):
+ # Flat file tests.
+ response = self.client.get('/photos/2018/PhilipSargent/corin.jpg')
+ if response.status_code != 200:
+ self.assertEqual(response.status_code, 302)
+ if response.status_code != 302:
+ self.assertEqual(response.status_code, 200)
+ self.assertEqual(len(response.content), 67487 )
+
+ def test_page_photos_not_ok(self):
+ # Flat file tests.
+ response = self.client.get('/photos/2018/PhilipSargent/corin.jpeg')
+ self.assertEqual(response.status_code, 200)
+ content = response.content.decode()
+ ph = r'Page not found 2018/PhilipSargent/corin.jpeg'
+ phmatch = re.search(ph, content)
+ self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph +"'")
+
+ def test_page_photos_dir(self):
+ # Flat file tests.
+ response = self.client.get('/photos/2018/PhilipSargent/')
+ self.assertEqual(response.status_code, 200)
+ content = response.content.decode()
+ ph = r'Directory not displayed'
+ phmatch = re.search(ph, content)
+ self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph +"'")
def test_page_survey_scans_empty(self):
# this gets an empty page as the database has not been loaded
diff --git a/localsettings.py b/localsettings.py
index b0853e7..3f44d36 100644
--- a/localsettings.py
+++ b/localsettings.py
@@ -29,7 +29,7 @@ from credentials import EXPOUSERPASS
from credentials import EMAIL_HOST_PASSWORD
SERVERPORT = '8000'
-EXPOFILESREMOTE = False # if True, then re-routes urls in expofiles to remote sever
+EXPOFILESREMOTE = False # if True, then re-routes urls in expofiles to remote sever. Tests are then less accurate.
#SECURE_SSL_REDIRECT = True # breaks 7 tests in test suite 301 not 200 (or 302) and runserver fails completely
# --------------------- MEDIA redirections BEGIN ---------------------
diff --git a/urls.py b/urls.py
index 2ba8120..cd3bff7 100644
--- a/urls.py
+++ b/urls.py
@@ -40,7 +40,7 @@ else:
expofilesurls = [
url(r'^(?P.*)$', expofilessingle, name="single"), # local copy of EXPOFILES
]
-
+
trogglepatterns = [
url(r'^expofiles/', include(expofilesurls)),