Validate / validate (push) Canceled after 0s
web/ is a static site generator for the dataset, in Python's standard library only. `python3 web/build.py --out _site` writes a page for each of the 138 records, a finder on the home page with a map of the 85 lines, region and route indexes, and the repository's documents as pages. Each line is offered as the record's GeoJSON and as a GPX simplified to 5 m, with two archives of everything. The site's name and address are set in web/site.toml: Long Hikes, at https://longhikes.org. The dataset keeps its own name. netlify.toml and web/static/_headers configure the Netlify site (content types, download dispositions, caching, a content security policy with no inline script). It is deployed with the Netlify CLI from a local build, because Netlify cannot build from this forge. MapLibre GL JS and the two typefaces are vendored under web/assets/; map tiles come from OpenFreeMap. Tests: python3 -m unittest discover -s web/tests (164). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
49 lines
1.8 KiB
Python
49 lines
1.8 KiB
Python
import os
|
|
import sys
|
|
import unittest
|
|
|
|
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
|
|
from olt import records # noqa: E402
|
|
|
|
|
|
class RecordsTest(unittest.TestCase):
|
|
@classmethod
|
|
def setUpClass(cls):
|
|
cls.recs = records.load_records()
|
|
|
|
def test_counts(self):
|
|
self.assertEqual(len(self.recs), 138)
|
|
self.assertEqual(sum(r["derived"]["kind"] == "route" for r in self.recs), 34)
|
|
self.assertEqual(sum(r["derived"]["kind"] == "designated" for r in self.recs), 104)
|
|
self.assertEqual(sum(r["derived"]["has_line"] for r in self.recs), 85)
|
|
|
|
def test_sorted_by_id(self):
|
|
ids = [r["id"] for r in self.recs]
|
|
self.assertEqual(ids, sorted(ids))
|
|
|
|
def test_derived_fields(self):
|
|
by_id = {r["id"]: r for r in self.recs}
|
|
ct = by_id["colorado-trail"]
|
|
self.assertEqual(ct["derived"]["status"], "included")
|
|
self.assertEqual(ct["derived"]["length_mi"], 486)
|
|
self.assertEqual(sorted(ct["derived"]["files"]["extracts"]), ["osm", "usfs"])
|
|
self.assertEqual(ct["derived"]["files"]["line"], "colorado-trail/line.geojson")
|
|
self.assertEqual(ct["name"], "Colorado Trail") # TOML fields unchanged
|
|
|
|
def test_status_matches_csv(self):
|
|
import csv
|
|
path = os.path.join(records.ROOT, "trails.csv")
|
|
with open(path, encoding="utf-8", newline="") as f:
|
|
status = {row["id"]: row["status"] for row in csv.DictReader(f)}
|
|
for r in self.recs:
|
|
self.assertEqual(r["derived"]["status"], status[r["id"]])
|
|
|
|
def test_line_file_exists_when_has_line(self):
|
|
for r in self.recs:
|
|
self.assertEqual(r["derived"]["has_line"], "line" in r["derived"]["files"])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|