2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-25 08:41:51 +00:00

more tests

This commit is contained in:
Philip Sargent 2023-04-06 00:51:04 +01:00
parent dcfff1ede7
commit f15555a3bd
5 changed files with 310 additions and 20 deletions

131
_cave-fixopenqms.html Normal file
View File

@ -0,0 +1,131 @@
<!DOCTYPE html>
<!-- base.html - this text visible because this template has been included -->
<html lang="en">
<head>
<script>document.interestCohort = null;</script> <!-- Turn off Google FLoC -->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="/site_media/css/trog3.css" title="troggle-style"/>
<title>Troggle Error - Bad Slug</title>
</head>
<body>
<div id="header">
<h1>CUCC Expeditions to Austria: 1976 - 2022</h1>
<div id="editLinks">
<a href="/">Home</a> |
<a id="cuccLink" href="http://camcaving.uk/">CUCC</a> |
<a id="expoWebsiteLink" href="http://expo.survex.com">expo.survex</a> |
<a id="handbook" href="/handbook/computing/onlinesystems.html">Handbook</a> |
<a href='/accounts/login/'>Log in</a>
</div>
</div>
<div class="toolbarlinks">
<a href="/survexfile/caves-1623/264/264.svx">264</a> |
<a href="/survexfile/caves-1623/290/290.svx">290</a> |
<a href="/survexfile/caves-1626/359/359.svx">359</a> |
<a href="/survexfile/">Survex</a> |
<a href="/survexfile/caves/">All Survex</a> |
<a href="/survey_scans/">Scans</a> |
<a href="/walletedit/">Upload Scans</a> |
<a href="/dwgfiles/">Drawings</a> |
<a href="/dwgupload/">Upload Drawings</a> |
<a href="/photoupload/">Upload Photos</a> |
<a href="/1623/290/290">290 (FGH)</a> |
<a href="/1623/264/264.html">264 (Balkonh&ouml;hle)</a> |
<br>
<a href="/dataissues">Data Issues</a> |
<a href="/handbook/computing/todo-data.html">tasks to do </a> |
<a id="cavesLink" href="/indxal.htm">caves</a> |
<a id="qmsLink" href="/cave/qms/1623-290">QMs</a> |
<a id="entsLink" href="/eastings">ents</a> |
<a id="folklink" href="/folk">expoers</a> |
<a id="caversLink" href="/people">survey lengths</a> |
<a href="/stats">statistics</a> |
<a href="/wallets/year/2022">Wallets(2022)</a> |
<a href="/expedition/2022">Expo(2022)</a> |
<a href="/controlpanel">Control panel</a> |
</div>
<div id="nav">
<!-- Not used any more? -->
</div>
<div id="content" >
<div id="related">
</div>
<div class='middle'>
<h2>Bad Slug Error</h2>
</div>
<div class='middle3 login'>
<div class='space'></div>
<div class='align-center'>
<h3>There has been a Troggle error. </h3>
<h4>
A Cave, Entrance or QM has been referred to using a label (a 'slug') which does not work.
<p>This is the bad slug:
<font color="red">
1623-284 - from caveQMs()
</font>
<p>
This is the previous page which had the bad slug reference on it: <font color="red">
<script type="text/javascript">
document.write(document.referrer);
</script>
</font>
</h4>
<p>
<p>It is also possible that the cave description page is being viewed using an alternative URL,
so that the local links in the page to other parts of the cave do not work.
<br>
e.g. /cave/1623-161 is not the correct way of looking at Kaninchenhohle,
<br>
you should be using <br>
/1623/161/top.htm instead.
<p>If that is the case, tell a nerd that we haven't fixed the fault that we thought we had fixed.
<div class='space'><p>&nbsp;</div>
<h3>What you should do now</h3>
<p>Please report the error by emailing the nerds at
<a href="mailto:expo-tech@lists.wookware.org">expo-tech@lists.wookware.org</a> with this information:
<ol>
<li>The bad slug text written in <font color="red">red</font> above.
<li>The previous page URL, also written in <font color="red">red</font> above
<li>Go back to this previous page <script type="text/javascript">
document.write("<a href='",document.referrer,"'>",document.referrer,"</a>");
</script>
and see if you can tell whether the bad slug was in HTML text which had been written manually, or whether it appeared to be a programming error.
</ol>
</div>
</div>
</div>
</div>
<div class="footer">
</div>
</body>
</html>

131
_cave-fixqms.html Normal file
View File

@ -0,0 +1,131 @@
<!DOCTYPE html>
<!-- base.html - this text visible because this template has been included -->
<html lang="en">
<head>
<script>document.interestCohort = null;</script> <!-- Turn off Google FLoC -->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="/site_media/css/trog3.css" title="troggle-style"/>
<title>Troggle Error - Bad Slug</title>
</head>
<body>
<div id="header">
<h1>CUCC Expeditions to Austria: 1976 - 2022</h1>
<div id="editLinks">
<a href="/">Home</a> |
<a id="cuccLink" href="http://camcaving.uk/">CUCC</a> |
<a id="expoWebsiteLink" href="http://expo.survex.com">expo.survex</a> |
<a id="handbook" href="/handbook/computing/onlinesystems.html">Handbook</a> |
<a href='/accounts/login/'>Log in</a>
</div>
</div>
<div class="toolbarlinks">
<a href="/survexfile/caves-1623/264/264.svx">264</a> |
<a href="/survexfile/caves-1623/290/290.svx">290</a> |
<a href="/survexfile/caves-1626/359/359.svx">359</a> |
<a href="/survexfile/">Survex</a> |
<a href="/survexfile/caves/">All Survex</a> |
<a href="/survey_scans/">Scans</a> |
<a href="/walletedit/">Upload Scans</a> |
<a href="/dwgfiles/">Drawings</a> |
<a href="/dwgupload/">Upload Drawings</a> |
<a href="/photoupload/">Upload Photos</a> |
<a href="/1623/290/290">290 (FGH)</a> |
<a href="/1623/264/264.html">264 (Balkonh&ouml;hle)</a> |
<br>
<a href="/dataissues">Data Issues</a> |
<a href="/handbook/computing/todo-data.html">tasks to do </a> |
<a id="cavesLink" href="/indxal.htm">caves</a> |
<a id="qmsLink" href="/cave/qms/1623-290">QMs</a> |
<a id="entsLink" href="/eastings">ents</a> |
<a id="folklink" href="/folk">expoers</a> |
<a id="caversLink" href="/people">survey lengths</a> |
<a href="/stats">statistics</a> |
<a href="/wallets/year/2022">Wallets(2022)</a> |
<a href="/expedition/2022">Expo(2022)</a> |
<a href="/controlpanel">Control panel</a> |
</div>
<div id="nav">
<!-- Not used any more? -->
</div>
<div id="content" >
<div id="related">
</div>
<div class='middle'>
<h2>Bad Slug Error</h2>
</div>
<div class='middle3 login'>
<div class='space'></div>
<div class='align-center'>
<h3>There has been a Troggle error. </h3>
<h4>
A Cave, Entrance or QM has been referred to using a label (a 'slug') which does not work.
<p>This is the bad slug:
<font color="red">
1623-284 - from caveQMs()
</font>
<p>
This is the previous page which had the bad slug reference on it: <font color="red">
<script type="text/javascript">
document.write(document.referrer);
</script>
</font>
</h4>
<p>
<p>It is also possible that the cave description page is being viewed using an alternative URL,
so that the local links in the page to other parts of the cave do not work.
<br>
e.g. /cave/1623-161 is not the correct way of looking at Kaninchenhohle,
<br>
you should be using <br>
/1623/161/top.htm instead.
<p>If that is the case, tell a nerd that we haven't fixed the fault that we thought we had fixed.
<div class='space'><p>&nbsp;</div>
<h3>What you should do now</h3>
<p>Please report the error by emailing the nerds at
<a href="mailto:expo-tech@lists.wookware.org">expo-tech@lists.wookware.org</a> with this information:
<ol>
<li>The bad slug text written in <font color="red">red</font> above.
<li>The previous page URL, also written in <font color="red">red</font> above
<li>Go back to this previous page <script type="text/javascript">
document.write("<a href='",document.referrer,"'>",document.referrer,"</a>");
</script>
and see if you can tell whether the bad slug was in HTML text which had been written manually, or whether it appeared to be a programming error.
</ol>
</div>
</div>
</div>
</div>
<div class="footer">
</div>
</body>
</html>

View File

@ -10,6 +10,8 @@ from django.test import Client, TestCase
from troggle.core.models.caves import Area, Cave
from troggle.core.models.troggle import Person, PersonExpedition
# import troggle.settings as settings
# FIXTURE_DIRS = settings.PYTHON_PATH / "core" /"fixtures"
class FixtureTests(TestCase):
"""These just hit the database.
@ -75,7 +77,8 @@ class FixtureTests(TestCase):
class FixturePageTests(TestCase):
"""Currently nothing that runs troggle works - all do 404. Must be something in a template rendering crash?
ordinary pages are OK, and expopages and expofiles are OK, even though they come through troggle.
ordinary pages are OK, and expopages and expofiles are OK, even though they come through troggle. And the
fixtures are certainly loaded into the db as the other tests show.
"""
# The fixtures have a password hash which is compatible with plain-text password 'secretword'
@ -150,7 +153,7 @@ class FixturePageTests(TestCase):
content = response.content.decode()
phmatch = re.search(ph, content)
# with open('cave-op.html', 'w') as f:
# with open('cave-url284.html', 'w') as f:
# f.write(content)
self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph + "'")
@ -176,20 +179,45 @@ class FixturePageTests(TestCase):
phmatch = re.search(ph, content)
self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph + "'") # 200 & Page Not Found
def test_fix_qms(self):
response = self.client.get("/cave/qms/1623-284")
def test_fix_caves284(self):
response = self.client.get("/caves")
self.assertEqual(response.status_code, HTTPStatus.OK)
content = response.content.decode()
ph = r"Question marks for 284 - Seetrichter"
phmatch = re.search(ph, content)
self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph + "'")
def test_fix_openqms(self):
response = self.client.get("/cave/openqms/1623-284")
self.assertEqual(response.status_code, HTTPStatus.OK)
content = response.content.decode()
ph = r"Open Leads for 284 - Seetrichter"
ph = r"284 Seetrichter"
phmatch = re.search(ph, content)
# with open('_cave_fix_caves.html', 'w') as f:
# f.write(content)
self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph + "'")
def test_fix_cavehtml284(self):
response = self.client.get("/1623/284/284.html")
self.assertEqual(response.status_code, HTTPStatus.OK)
content = response.content.decode()
ph = r"A 25m long (22m deep) resurgence in Altausee"
phmatch = re.search(ph, content)
with open('_cave_fix_cavehtml284.html', 'w') as f:
f.write(content)
self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph + "'")
# def test_fix_qms(self):
# response = self.client.get("/cave/qms/1623-284")
# self.assertEqual(response.status_code, HTTPStatus.OK)
# content = response.content.decode()
# ph = r"Question marks for 284 - Seetrichter"
# phmatch = re.search(ph, content)
# with open('_cave-fixqms.html', 'w') as f:
# f.write(content)
# self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph + "'")
# def test_fix_openqms(self):
# response = self.client.get("/cave/openqms/1623-284")
# self.assertEqual(response.status_code, HTTPStatus.OK)
# content = response.content.decode()
# ph = r"Open Leads for 284 - Seetrichter"
# phmatch = re.search(ph, content)
# with open('_cave-fixopenqms.html', 'w') as f:
# f.write(content)
# self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph + "'")

View File

@ -151,8 +151,8 @@ class PostTests(TestCase):
)
content = response.content.decode()
self.assertEqual(response.status_code, HTTPStatus.OK)
with open("_test_response.html", "w") as f:
f.write(content)
# with open("_test_response.html", "w") as f:
# f.write(content)
for ph in [
r"test_upload_",
rf"&larr; {testyear}#00 &rarr;",

View File

@ -118,8 +118,8 @@ class ImportTest(TestCase):
response = self.client.get("/survexfile/caves/")
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)
ph = f"Caves with subdirectories"
phmatch = re.search(ph, content)
self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph + "'")
@ -130,8 +130,8 @@ class ImportTest(TestCase):
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)
# 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 + "'")