Use NaPTAN data for the UK stop finder
Import active NaPTAN stops into a local SQLite spatial index, including conversion of British National Grid coordinates. Add local searches, shareable stop links, source details and transport mode colours while retaining OSM route lookup by ATCO code. Closes #1
This commit is contained in:
parent
8ed7b8d112
commit
29afb4f115
12 changed files with 503 additions and 55 deletions
|
|
@ -320,3 +320,33 @@ def test_mobile_postcode_is_fitted_above_results_sheet(
|
|||
}""")
|
||||
assert 0 < position["markerY"] < position["visibleBottom"]
|
||||
page.close()
|
||||
|
||||
|
||||
def test_naptan_shared_stop_and_osm_routes(chromium_browser: Any, flask_url: str) -> None:
|
||||
"""NaPTAN links survive reload and show source fields plus matched OSM routes."""
|
||||
page = chromium_browser.new_page(viewport={"width": 1280, "height": 800})
|
||||
errors: list[str] = []
|
||||
page.on("pageerror", lambda error: errors.append(str(error)))
|
||||
stop = {
|
||||
"type": "naptan", "source": "NaPTAN", "id": "0100BRP90317",
|
||||
"lat": 51.44827, "lon": -2.58302, "name": "Temple Meads Stn",
|
||||
"atco_code": "0100BRP90317", "indicator": "T1", "bearing": "SE",
|
||||
"transport_type": "Bus stop", "tags": {"CommonName": "Temple Meads Stn", "Status": "active"},
|
||||
}
|
||||
page.route("**/api/stop/naptan/0100BRP90317", lambda route: route.fulfill(json={"stop": stop}))
|
||||
page.route("**/api/stop/naptan/0100BRP90317/routes", lambda route: route.fulfill(json={
|
||||
"matched_stops": 1, "routes": [{"id": 12, "ref": "A1", "name": "Airport bus"}],
|
||||
}))
|
||||
page.route("**/api/stops/in-bounds?*", lambda route: route.fulfill(json={"kind": "map", "stops": [stop]}))
|
||||
page.goto(f"{flask_url}/?naptan=0100BRP90317")
|
||||
expect = playwright_api.expect
|
||||
for _ in range(2):
|
||||
expect(page.locator("#stop-name")).to_have_text("Temple Meads Stn")
|
||||
expect(page.locator("#stop-source")).to_contain_text("NaPTAN")
|
||||
expect(page.locator("#tags-heading")).to_have_text("NaPTAN stop data")
|
||||
expect(page.locator("#osm-link")).not_to_be_visible()
|
||||
expect(page.locator("#route-list")).to_contain_text("A1")
|
||||
assert "naptan=0100BRP90317" in page.url
|
||||
page.reload()
|
||||
assert errors == []
|
||||
page.close()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue