feat(places): registry of towns and authorities

Two namespaces because 67 town names collide with an authority name and
neither set contains the other — postal towns cross authority boundaries, so
Bedford the town holds 104 schools against the authority's 86.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015mWQnpye9F299NVRCCSRvj
This commit is contained in:
TudorandClaude Opus 5 committed 2026-08-21 18:10:37 +01:00
1 parent 555d3f0a7d
commit 759d9f5cea
3 files changed
+184 -3

No files matched your search

@@ -132,9 +132,12 @@ def _df(rows: list[dict]) -> pd.DataFrame:
return pd.DataFrame([{**base, **r} for r in rows])
def _town(n: int, town: str, la: str, **kw) -> list[dict]:
def _town(n: int, town: str, la: str, start: int = 100000, **kw) -> list[dict]:
"""`start` offsets the URNs so two calls can describe different schools —
the Bedford case needs two authorities' worth of distinct URNs in one
town."""
return [
{"urn": 100000 + i, "school_name": f"{town} School {i}",
{"urn": start + i, "school_name": f"{town} School {i}",
"town": town, "local_authority": la, **kw}
for i in range(n)
]
@@ -164,7 +167,7 @@ def test_town_and_authority_of_the_same_name_are_separate_places():
# 104 schools, Bedford the authority 86, because postal towns cross
# authority boundaries.
rows = (_town(MIN_SCHOOLS, "Bedford", "Bedford")
+ _town(MIN_SCHOOLS, "Bedford", "Central Bedfordshire"))
+ _town(MIN_SCHOOLS, "Bedford", "Central Bedfordshire", start=200000))
reg = build_place_registry(_df(rows))
town, authority = reg["town:bedford"], reg["authority:bedford"]
assert set(town.urns) != set(authority.urns)