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

new test for logbook

This commit is contained in:
Philip Sargent 2023-02-24 20:21:06 +00:00
parent d1dac92034
commit 3d38611e4f
2 changed files with 24 additions and 3 deletions

View File

@ -143,6 +143,25 @@ class SimpleTest(SimpleTestCase):
from troggle.core.views.statistics import dataissues, pathsreport, stats
from troggle.core.views.survex import survexcavesingle, survexcaveslist, svx
class ImportTest(TestCase):
@classmethod
def setUpTestData(cls):
import troggle.settings as settings
from troggle.parsers.logbooks import LOGBOOKS_DIR, DEFAULT_LOGBOOK_FILE
LOGBOOKS_PATH = settings.EXPOWEB / LOGBOOKS_DIR
test_year = "1986"
self.test_logbook = LOGBOOKS_PATH / test_year / DEFAULT_LOGBOOK_FILE
def setUp(self):
pass
def tearDown(self):
pass
def test_logbook_exists(self):
self.assertTrue(self.test_logbook.is_file())
class SubprocessTest(TestCase):
@classmethod

View File

@ -56,6 +56,7 @@ DEFAULT_LOGBOOK_PARSER = "parser_html"
LOGBOOK_PARSER_SETTINGS = {
"1982": ("logbook.html", "parser_html"),
}
LOGBOOKS_DIR = "years" # subfolder of settings.EXPOWEB
ENTRIES = {
"2022": 90,
@ -97,6 +98,7 @@ ENTRIES = {
"1983": 52,
"1982": 42,
}
# What about 1970s ! Yes, 80 and 81 are missing, but the older ones need re-parsing !!!
logentries = [] # the entire logbook for one year is a single object: a list of entries
noncaveplaces = ["travel", "Journey", "Loser Plateau", "UNKNOWN", "plateau", "base camp", "basecamp", "top camp", "topcamp"]
@ -294,7 +296,7 @@ def parser_html(year, expedition, txt, seq=""):
# print(f" - headpara:\n'{headpara}'")
if len(headpara) > 0:
frontpath = Path(settings.EXPOWEB, "years", year, "frontmatter.html")
frontpath = Path(settings.EXPOWEB, LOGBOOKS_DIR, year, "frontmatter.html")
with open(frontpath, "w") as front:
front.write(headpara + "\n")
@ -304,7 +306,7 @@ def parser_html(year, expedition, txt, seq=""):
# print(f" - endpara:\n'{endpara}'")
if len(endpara) > 0:
endpath = Path(settings.EXPOWEB, "years", year, "endmatter.html")
endpath = Path(settings.EXPOWEB, LOGBOOKS_DIR, year, "endmatter.html")
with open(endpath, "w") as end:
end.write(endpara + "\n")
@ -511,7 +513,7 @@ def parse_logbook_for_expedition(expedition, blog=False):
logentries = []
logbook_parseable = False
expologbase = Path(settings.EXPOWEB, "years")
expologbase = Path(settings.EXPOWEB, LOGBOOKS_DIR)
year = expedition.year
expect = ENTRIES[year]