Let a place carry its own label and preposition, keep the count in every place title, and test that slugs follow names

A registry entry may now set label and prep. A plateau reads "Plateau" and "on the Colorado
Plateau", the Mogollon Rim "Escarpment" and "along the Mogollon Rim", a national monument or a
parkway its own word; the default is still "Mountain range" and "in the". Every national park,
provincial park, monument, recreation area and parkway in the registry is labelled.

A place title no longer gives up its ": N Trails" ending when it is long: it drops the state first
and then keeps the count over the cap, and the state is left out where the name already holds
it (Oregon Cascades, California Coast Ranges). A test checks that every slug is the slug of its
display name, with the Arizona White Mountains as the one stated exception.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Sonnet 5.5 committed 2026-11-20 12:28:03 -07:00
1 parent a97ea85093
commit 30d03b8069
10 files changed
+307 -43

No files matched your search

+10
View File
@@ -605,6 +605,16 @@ class ApplyTest(unittest.TestCase):
P.apply(self.pjson, self.root, "2026-12-01")
self.assertEqual(read_toml(path)["place"][0]["where"], ["MT", "WY"])
def test_a_reviewed_label_and_preposition_survive_a_rerun(self):
P.apply(self.pjson, self.root, "2026-11-20")
path = os.path.join(self.root, "places.toml")
text = open(path).read()
open(path, "w").write(text.replace('name = "Alpha Park"',
'name = "Alpha Park"\nlabel = "National park"\nprep = "along the"'))
P.apply(self.pjson, self.root, "2026-12-01")
entry = read_toml(path)["place"][0]
self.assertEqual((entry["label"], entry["prep"]), ("National park", "along the"))
def test_stated_requires_an_http_source_a_quote_and_a_trackless_record(self):
P.apply(self.pjson, self.root, "2026-11-20")
with self.assertRaises(ValueError):
+39
View File
@@ -86,6 +86,45 @@ class RegistryTest(unittest.TestCase):
self.assertTrue(any("box" in m for m in registry_errors([entry(box=bad)])), bad)
class LabelAndPrepositionTest(unittest.TestCase):
def test_a_label_and_a_preposition_are_allowed_and_checked(self):
self.assertEqual(registry_errors([entry(label="Plateau", prep="on the")]), [])
self.assertEqual(registry_errors([entry(label="Parkway", prep="along the", kind="park")]), [])
self.assertTrue(any("label" in m for m in registry_errors([entry(label="")])))
self.assertTrue(any("label" in m for m in registry_errors([entry(label=3)])))
self.assertTrue(any("prep" in m for m in registry_errors([entry(prep="over the hills")])))
self.assertTrue(any("prep" in m for m in registry_errors([entry(prep="")])))
def test_every_place_that_is_not_a_mountain_range_names_its_own_label(self):
with open(os.path.join(ROOT, "places.toml"), "rb") as f:
import tomllib
reg = tomllib.load(f)["place"]
for e in reg:
if e["kind"] == "park":
self.assertTrue(e.get("label"), f"{e['slug']} needs a label")
by = {e["slug"]: e for e in reg if e["kind"] == "range"}
for slug in ("colorado-plateau", "allegheny-plateau"):
self.assertEqual((by[slug]["label"], by[slug]["prep"]), ("Plateau", "on the"))
self.assertEqual(by["mogollon-rim"]["prep"], "along the")
self.assertNotEqual(by["mogollon-rim"].get("label"), "Mountain range")
class SlugTest(unittest.TestCase):
EXCEPTIONS = {("range", "white-mountains-arizona"): "the White Mountains of Arizona share a "
"display name with the ones of New Hampshire and Maine"}
def test_every_slug_is_the_slugified_display_name(self):
import tomllib
import place_trails
with open(os.path.join(ROOT, "places.toml"), "rb") as f:
reg = tomllib.load(f)["place"]
bad = [f"{e['kind']}/{e['slug']} (name {e['name']!r})" for e in reg
if (e["kind"], e["slug"]) not in self.EXCEPTIONS
and e["slug"] != place_trails.slugify(e["name"])]
self.assertEqual(bad, [])
self.assertEqual(len(self.EXCEPTIONS), 1)
class RecordTest(unittest.TestCase):
def test_record_place_must_be_in_the_registry(self):
rec = record(place=[{"kind": "range", "slug": "no-such", "basis": "stated",