"""Tests for the generated HTML pages (web/olt/pages.py and friends).
The first run builds the whole site into web/.cache/test-site (about a minute:
every line is simplified); later runs are incremental and take seconds.
"""
import html
import os
import re
import subprocess
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, site, trail, words # noqa: E402
OUT = os.path.join(WEB, ".cache", "test-site")
# 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()