mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-22 15:21:52 +00:00
44 lines
1.5 KiB
Python
44 lines
1.5 KiB
Python
"""
|
|
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
|
|
self.user = User.objects.get(username='expotest')
|
|
|
|
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 +"'")
|
|
|
|
|