Now 99 tests

This commit is contained in:
2023-03-03 15:15:17 +00:00
parent 1cb81cbb09
commit 6ab7a340e2
3 changed files with 131 additions and 4 deletions

View File

@@ -21,6 +21,7 @@ https://docs.djangoproject.com/en/dev/topics/testing/tools/
import re
import subprocess
import unittest
from http import HTTPStatus
from django.test import Client, SimpleTestCase, TestCase
@@ -99,4 +100,28 @@ class ImportTest(TestCase):
for e in expected:
self.assertIn(e, messages)
for e in not_expected:
self.assertNotIn(e, messages)
self.assertNotIn(e, messages)
def test_aliases(self):
# Needs another test with test data
response = self.client.get(f"/aliases/{TEST_YEAR}")
self.assertEqual(response.status_code, HTTPStatus.OK)
content = response.content.decode()
with open('_test_response.html', 'w') as f:
f.write(content)
ph = f"'fsmartarse'"
phmatch = re.search(ph, content)
self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph + "'")
def test_people(self):
# Needs another test with test data
response = self.client.get("/people")
self.assertEqual(response.status_code, HTTPStatus.OK)
content = response.content.decode()
with open('_test_response.html', 'w') as f:
f.write(content)
ph = f"<td><a href=\"/personexpedition/FredSmartarse/{TEST_YEAR}\">{TEST_YEAR}</a></td>"
phmatch = re.search(ph, content)
self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph + "'")