Files
longhikes/tools/tests/test_guides.py
T
swaitsandClaude Fable 5.2 24bfbb2fa8
Mirror to forge / mirror (push) Canceled after 0s
Validate / validate (push) Canceled after 0s
Validate / history (push) Canceled after 0s
Validate / site (push) Canceled after 0s
Validate / deploy (push) Canceled after 0s
Show each trail's own emblem, keep a history on every record, and list what was left out
- Emblems for 81 trails, up from 41. Each is the trail's own crest, badge
  or roundel alone, cropped out of a larger logo where need be and made
  transparent where that could be done cleanly. Records without one say
  where an emblem was looked for. The validator checks the logo state.
- Every record has a `[[history]]` list: what changed or was asked for,
  on what basis, who asked and whether it was applied or declined.
  `tools/check_history.py` fails a changed fact with no history entry and
  prints earlier entries about a changed field. It runs in CI before the
  site deploys. Each trail page shows the history.
- A new page, "Considered and left out", built from `left-out.toml`:
  35 trails and routes with the reason, the deciding fact and its source.
- The Hoosier Heritage Trail has its ends, its free map set and its
  emblem from its association (issue 2). Any trail may list its holder's
  own guide or map set.
- A stated permission is quoted in the download credit box.
- `tools/gpx_track.py` turns a GPX file from a holder or a hiker into a
  record's track files.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-16 13:40:03 -07:00

44 lines
1.3 KiB
Python

"""[[guide]] on a trail that is not a route: its holder's own guide or map set."""
import os
import sys
import unittest
sys.dont_write_bytecode = True
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import validate as V # noqa: E402
GOOD = {"title": "Guide and Map Set", "author": "An Association", "access": "free",
"url": "https://example.org/mapset.pdf", "format": "PDF"}
def check(guides):
errors = []
V.check_guides("t", guides, errors)
return errors
class GuideTest(unittest.TestCase):
def test_no_guide_is_fine(self):
self.assertEqual(check(None), [])
def test_a_complete_guide_passes(self):
self.assertEqual(check([dict(GOOD)]), [])
def test_each_required_field(self):
for field in ("title", "author", "access", "url"):
errors = check([{k: v for k, v in GOOD.items() if k != field}])
self.assertTrue(errors, field)
def test_access_and_url_are_checked(self):
self.assertTrue(check([dict(GOOD, access="gift")]))
self.assertTrue(check([dict(GOOD, url="ftp://example.org/x")]))
def test_price_needs_its_date(self):
self.assertTrue(check([dict(GOOD, price="$5")]))
self.assertEqual(check([dict(GOOD, price="$5", price_checked="2026-11-16")]), [])
if __name__ == "__main__":
unittest.main()