fix template bug for newentrance

This commit is contained in:
Philip Sargent
2021-04-17 23:59:11 +01:00
parent d4317b5fd3
commit eea74406c9
8 changed files with 72 additions and 46 deletions

View File

@@ -5,11 +5,13 @@ Modified for Expo April 2021.
import unittest
import re
from django.test import TestCase, SimpleTestCase, TransactionTestCase, Client
from troggle.core.models.caves import Cave
class FixturePageTests(TestCase):
# The fixtures have a password hash which is compatible with plain-text password 'secretword'
fixtures = ['auth_users', 'expo_areas', 'expo_caves']
ph = r'and leads in 800m of tortuous going to'
def setUp(self):
from django.contrib.auth.models import User
@@ -18,4 +20,25 @@ class FixturePageTests(TestCase):
def tearDown(self):
pass
def test_fix_cave_loaded(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.filename), "1623-115.html")
ph = self.ph
phmatch = re.search(ph, c.underground_description)
self.assertIsNotNone(phmatch, "In fixture-loaded cave, failed to find expected text: '" + ph +"'")
def test_fix_cave_url(self):
ph = self.ph
response = self.client.get('1623/115.htm')
#self.assertEqual(response.status_code, 200)
content = response.content.decode()
phmatch = re.search(ph, content)
with open('cave-op.html', 'w') as f:
f.write(content)
self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph +"'")