forked from expo/troggle
tests for new /site_media/ management
This commit is contained in:
parent
2690203912
commit
8f790309ce
@ -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'<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 +"'")
|
||||
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_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'<a href="/expofiles/surveyscans/2004">/2004/',
|
||||
r'<a href="/expofiles/surveyscans/1989LUSS">/1989LUSS/',
|
||||
r'<a href="/expofiles/surveyscans/2018">/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'<a href="/expofiles/surveyscans/2004">/2004/',
|
||||
r'<a href="/expofiles/surveyscans/1989LUSS">/1989LUSS/',
|
||||
r'<a href="/expofiles/surveyscans/2018">/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'<title>Page not found 2018/PhilipSargent/corin.jpeg</title>'
|
||||
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
|
||||
|
@ -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 ---------------------
|
||||
|
Loading…
Reference in New Issue
Block a user