diff options
author | Philip Sargent <philip.sargent@gmail.com> | 2023-03-03 15:15:17 +0000 |
---|---|---|
committer | Philip Sargent <philip.sargent@gmail.com> | 2023-03-03 15:15:17 +0000 |
commit | 6ab7a340e2c635dca0578cce3ebf4d85d5f9c9c3 (patch) | |
tree | e39b979eeb1dc0f2746ea06b065fc6b1981b2558 /core | |
parent | 1cb81cbb093575bdc4b8eaf7c3b3b352ef248c94 (diff) | |
download | troggle-6ab7a340e2c635dca0578cce3ebf4d85d5f9c9c3.tar.gz troggle-6ab7a340e2c635dca0578cce3ebf4d85d5f9c9c3.tar.bz2 troggle-6ab7a340e2c635dca0578cce3ebf4d85d5f9c9c3.zip |
Now 99 tests
Diffstat (limited to 'core')
-rw-r--r-- | core/TESTS/test_parsers.py | 27 | ||||
-rw-r--r-- | core/TESTS/tests.py | 65 |
2 files changed, 91 insertions, 1 deletions
diff --git a/core/TESTS/test_parsers.py b/core/TESTS/test_parsers.py index 85869d3..44b9d8a 100644 --- a/core/TESTS/test_parsers.py +++ b/core/TESTS/test_parsers.py @@ -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)
\ No newline at end of file + 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 + "'") +
\ No newline at end of file diff --git a/core/TESTS/tests.py b/core/TESTS/tests.py index c663df6..fc6f12b 100644 --- a/core/TESTS/tests.py +++ b/core/TESTS/tests.py @@ -476,6 +476,71 @@ class PageTests(TestCase): self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph + "'") + def test_statistics(self): + response = self.client.get("/statistics") + self.assertEqual(response.status_code, HTTPStatus.OK) + content = response.content.decode() + ph = r"0 expeditions: 0 people, 0 caves and 0 logbook entries." + phmatch = re.search(ph, content) + self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph + "'") + + def test_stats(self): + # Needs another test with test data + response = self.client.get("/stats") + self.assertEqual(response.status_code, HTTPStatus.OK) + content = response.content.decode() + ph = r"Total length: 0.0 km adding up the total for each year." + phmatch = re.search(ph, content) + self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph + "'") + + def test_dataissues(self): + # Needs another test with test data + response = self.client.get("/dataissues") + self.assertEqual(response.status_code, HTTPStatus.OK) + content = response.content.decode() + ph = r"as well as these import/parsing issues" + phmatch = re.search(ph, content) + self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph + "'") + + def test_therionissues(self): + # Needs another test with test data + response = self.client.get("/therionissues") + self.assertEqual(response.status_code, HTTPStatus.OK) + content = response.content.decode() + ph = r"! Un-parsed image filename" + phmatch = re.search(ph, content) + self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph + "'") + + def test_surveximport(self): + # Needs another test with test data + response = self.client.get("/surveximport") + self.assertEqual(response.status_code, HTTPStatus.OK) + content = response.content.decode() + # with open('_test_response.html', 'w') as f: + # f.write(content) + ph = r"The number at the left-hand margin is the depth" + phmatch = re.search(ph, content) + self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph + "'") + + def test_survexdebug(self): + # Needs another test with test data + response = self.client.get("/survexdebug") + self.assertEqual(response.status_code, HTTPStatus.OK) + content = response.content.decode() + ph = r"Running list of warnings during import" + phmatch = re.search(ph, content) + self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph + "'") + + def test_eastings(self): + # Needs another test with test data + response = self.client.get("/eastings") + self.assertEqual(response.status_code, HTTPStatus.OK) + content = response.content.decode() + ph = r"<tr><th>Survex Station</th><th>x</th><th>y</th></tr>" + phmatch = re.search(ph, content) + self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph + "'") + + # ADD TESTS when we are redirecting /expofiles/ to get the actual files using e.g. # import requests # page = requests.get("http://dataquestio.github.io/web-scraping-pages/simple.html") |