summaryrefslogtreecommitdiffstats
path: root/core/TESTS/test_parsers.py
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@gmail.com>2023-09-04 00:25:35 +0300
committerPhilip Sargent <philip.sargent@gmail.com>2023-09-04 00:25:35 +0300
commit3a04a8490e313e959fd91bf8059593e96d427d9e (patch)
tree7587dcbeb9dae6a2a2f224d85824c91b2442540b /core/TESTS/test_parsers.py
parent2c89cdc1b9a9f41a57816cabe5253ac90c035f23 (diff)
downloadtroggle-3a04a8490e313e959fd91bf8059593e96d427d9e.tar.gz
troggle-3a04a8490e313e959fd91bf8059593e96d427d9e.tar.bz2
troggle-3a04a8490e313e959fd91bf8059593e96d427d9e.zip
debugged lbe edit tests
Diffstat (limited to 'core/TESTS/test_parsers.py')
-rw-r--r--core/TESTS/test_parsers.py35
1 files changed, 21 insertions, 14 deletions
diff --git a/core/TESTS/test_parsers.py b/core/TESTS/test_parsers.py
index 218e4fd..fd87af3 100644
--- a/core/TESTS/test_parsers.py
+++ b/core/TESTS/test_parsers.py
@@ -24,6 +24,7 @@ from http import HTTPStatus
from django.test import Client, SimpleTestCase, TestCase
+from troggle.core.models.logbooks import LogbookEntry
from troggle.core.models.troggle import Expedition, DataIssue, Person, PersonExpedition
import troggle.parsers.logbooks as lbp
@@ -80,7 +81,7 @@ class ImportTest(TestCase):
def test_logbook_exists(self):
self.assertTrue(self.test_logbook.is_file())
- def test_logbook_parse(self):
+ def test_logbook_parse_issues(self):
"""This is just testing the db not the web page
"""
lbp.LoadLogbook(self.test_expo) # i.e. load the 1986 logbook
@@ -102,9 +103,9 @@ class ImportTest(TestCase):
" ! - 1986 Warning: logentry: surface - stupour - no expo member author for entry '1986-07-31a'",
" ! - 1986 Warning: logentry: 123 - wave 2 - no expo member author for entry '1986-08-01a'",
]
- with open('_test_response.txt', 'w') as f:
- for m in messages:
- f.write(m)
+ # with open('_test_response.txt', 'w') as f:
+ # for m in messages:
+ # f.write(m)
messages_text = ", ".join(messages)
for e in expected:
phmatch = re.search(e, messages_text)
@@ -119,7 +120,7 @@ class ImportTest(TestCase):
response = self.client.get(f"/logbookentry/1986-07-27/1986-07-27a")
self.assertEqual(response.status_code, HTTPStatus.OK)
content = response.content.decode()
- # with open('_test_response.html', 'w') as f:
+ # with open('_test_response_1986-07-27a.html', 'w') as f:
# f.write(content)
expected = [
"<title>Logbook CUCC expo-test 1986 123 - 123 Wave 1</title>",
@@ -139,11 +140,11 @@ class ImportTest(TestCase):
response = self.client.get(f"/logbookedit/")
self.assertEqual(response.status_code, HTTPStatus.OK)
content = response.content.decode()
- with open('_test_response.html', 'w') as f:
- f.write(content)
+ # with open('_test_response.html', 'w') as f:
+ # f.write(content)
expected = [
"New Logbook Entry in ",
- "Other names (comma separated)",
+ "Everyone else involved",
"Place: cave name, or 'plateau', 'topcamp' etc.",
]
for ph in expected:
@@ -152,18 +153,24 @@ class ImportTest(TestCase):
def test_lbe_edit(self):
+ """This page requires the user to be logged in first, hence the extra shenanigans
+ """
c = self.client
u = self.user
c.login(username=u.username, password="secretword")
-
- response = self.client.get(f"/logbookedit/1986-07-27a")
+
+ lbp.LoadLogbook(self.test_expo) # i.e. load the 1986 logbook, which has this logbook entry
+ # muliple loads are overwriting the lbes and incrementing the a, b, c etc, so get one that works
+ lbe = LogbookEntry.objects.get(date="1986-07-31") # only one on this date in fixture
+
+ response = self.client.get(f"/logbookedit/{lbe.slug}")
self.assertEqual(response.status_code, HTTPStatus.OK)
content = response.content.decode()
- with open('_test_response_edit.html', 'w') as f:
- f.write(content)
+ # with open('_test_response_edit.html', 'w') as f:
+ # f.write(content)
expected = [
- "Edit Logbook Entry on 1986-07-27",
- "Other names (comma separated)",
+ "Edit Logbook Entry on 1986-07-31",
+ "Other names \(comma separated\)", # regex so slashes need to be espcaped
"Place: cave name, or 'plateau', 'topcamp' etc.",
]
for ph in expected: