"""Tests for the generated HTML pages (web/olt/pages.py and friends). The whole site is built once per run, by builtsite.py, and read from there. """ import html import os import re import sys import tempfile import tomllib import unittest from html.parser import HTMLParser WEB = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) ROOT = os.path.dirname(WEB) sys.path.insert(0, WEB) from olt import home, layout, pages, records, regions, site, trail, words # noqa: E402 import builtsite # noqa: E402 OUT = builtsite.OUT # Linked from the shared navigation and footer; written by other page modules. # Remove a path from this set once its page exists. PENDING_PAGES = set() class Tags(HTMLParser): """Collect every start tag with its attributes, and ', doc) self.assertIsNotNone(tag) self.assertRegex(tag.group(1), r'data-maplibre-js="/immutable/maplibre-gl\.[0-9a-f]{10}\.js"') self.assertRegex(tag.group(1), r'data-maplibre-css="/immutable/maplibre-gl\.[0-9a-f]{10}\.css"') self.assertNotRegex(doc, r']*maplibre') self.assertNotRegex(doc, r'", "publisher": "P", "url": "https://one.example/", "note": ""}] body = trail.render(rec, site.Site("N", "T"))[2] self.assertNotIn(""}, "osm": {"relation": 0, "note": "None"}, "shield": {"status": "no-logo-exists", "logo_source": "", "contact": "P", "note": "None", "logo_file": "", "logo_owner": "P"}, "verification": {"verified": False, "note": "No line to measure."}, "derived": {"kind": "designated", "has_line": False, "length_mi": 62, "files": {}, "status": "record-only", "downloads": []}, } if __name__ == "__main__": unittest.main()