Remove obsolete connection template context

This commit is contained in:
Edward Betts 2026-05-27 00:27:16 +01:00
parent 1c230ce0d6
commit 5272956050
9 changed files with 423 additions and 229 deletions

View file

@ -73,12 +73,12 @@ def test_search_redirects_to_results_with_selected_params() -> None:
client = _client()
resp = client.get(
"/search?destination=rotterdam&travel_date=2026-04-10&min_connection=60&max_connection=120&station_crs=BRI"
"/search?destination=rotterdam&travel_date=2026-04-10&min_connection=60&station_crs=BRI"
)
assert resp.status_code == 302
assert resp.headers["Location"].endswith(
"/results/BRI/rotterdam/out/2026-04-10?min_connection=60&max_connection=120"
"/results/BRI/rotterdam/out/2026-04-10?min_connection=60"
)
@ -106,6 +106,35 @@ def test_search_redirects_inbound_to_back_path() -> None:
assert resp.headers["Location"].endswith("/results/BRI/paris/back/2026-04-10")
def test_search_uses_back_connection_fields_for_inbound() -> None:
client = _client()
resp = client.get(
"/search?journey_type=inbound&destination=paris&travel_date=2026-04-10"
"&station_crs=BRI&min_connection=50"
"&min_connection_back=40"
)
assert resp.status_code == 302
assert resp.headers["Location"].endswith(
"/results/BRI/paris/back/2026-04-10?min_connection=40"
)
def test_search_redirects_return_with_return_leg_connection() -> None:
client = _client()
resp = client.get(
"/search?journey_type=return&destination=paris&travel_date=2026-04-10"
"&return_date=2026-04-17&station_crs=BRI&min_connection_in=40"
)
assert resp.status_code == 302
assert resp.headers["Location"].endswith(
"/results/BRI/paris/return/2026-04-10/2026-04-17?min_connection_in=40"
)
def test_nr_weekday_cache_key_includes_timetable_period() -> None:
key = app_module._nr_weekday_cache_key("to_paddington", "BRI", "2026-06-22")
@ -117,7 +146,7 @@ def test_results_shows_same_day_destination_switcher(monkeypatch: Any) -> None:
client = _client()
resp = client.get(
"/results/BRI/paris/out/2026-04-10?min_connection=60&max_connection=120"
"/results/BRI/paris/out/2026-04-10?min_connection=60"
)
html = resp.get_data(as_text=True)
@ -125,11 +154,11 @@ def test_results_shows_same_day_destination_switcher(monkeypatch: Any) -> None:
assert "Switch destination for Friday 10 April 2026" in html
assert '<span class="chip-current">Paris Gare du Nord</span>' in html
assert (
"/results/BRI/brussels/out/2026-04-10?min_connection=60&amp;max_connection=120"
"/results/BRI/brussels/out/2026-04-10?min_connection=60"
in html
)
assert (
"/results/BRI/rotterdam/out/2026-04-10?min_connection=60&amp;max_connection=120"
"/results/BRI/rotterdam/out/2026-04-10?min_connection=60"
in html
)
assert "ES 9014" in html
@ -155,6 +184,13 @@ def test_results_can_render_from_weekday_timetable_cache(monkeypatch: Any) -> No
"train_number": "ES 9014",
},
],
app_module._walkon_weekday_cache_key("to_paddington", "BRI", travel_date): {
"07:00": {
"ticket": "Anytime Day Single",
"price": 138.70,
"code": "SDS",
},
},
}
monkeypatch.setattr(app_module, "get_cached", lambda key, ttl=None: cache.get(key))
monkeypatch.setattr(app_module, "set_cached", lambda key, data: None)
@ -182,7 +218,7 @@ def test_results_can_render_from_weekday_timetable_cache(monkeypatch: Any) -> No
client = _client()
resp = client.get(
"/results/BRI/paris/out/2026-06-22?min_connection=60&max_connection=120"
"/results/BRI/paris/out/2026-06-22?min_connection=60"
)
html = resp.get_data(as_text=True)
@ -190,6 +226,8 @@ def test_results_can_render_from_weekday_timetable_cache(monkeypatch: Any) -> No
assert "07:00 &rarr; 08:45" in html
assert "10:01 &rarr; 13:34" in html
assert "ES 9014" in html
assert "£138.70" in html
assert "Anytime Day Single" in html
assert "checking exact timetable" in html
assert "/api/results_refresh/BRI/paris/out/2026-06-22" in html
assert "refreshFullResults()" in html
@ -403,7 +441,7 @@ def test_results_title_and_social_meta_include_destination(monkeypatch: Any) ->
client = _client()
resp = client.get(
"/results/BRI/lille/out/2026-04-10?min_connection=60&max_connection=120"
"/results/BRI/lille/out/2026-04-10?min_connection=60"
)
html = resp.get_data(as_text=True)
@ -418,7 +456,7 @@ def test_results_title_and_social_meta_include_destination(monkeypatch: Any) ->
'to Lille Europe on Friday 10 April 2026 via Paddington, St Pancras, and Eurostar.">'
) in html
assert (
'<meta property="og:url" content="http://localhost/results/BRI/lille/out/2026-04-10?min_connection=60&amp;max_connection=120">'
'<meta property="og:url" content="http://localhost/results/BRI/lille/out/2026-04-10?min_connection=60">'
in html
)
@ -509,7 +547,7 @@ def test_results_marks_trips_within_five_minutes_of_fastest_and_slowest(
client = _client()
resp = client.get(
"/results/BRI/paris/out/2026-04-10?min_connection=60&max_connection=120"
"/results/BRI/paris/out/2026-04-10?min_connection=60"
)
html = resp.get_data(as_text=True)
@ -578,7 +616,7 @@ def test_results_shows_only_pre_first_reachable_unreachable_services(
client = _client()
resp = client.get(
"/results/BRI/paris/out/2026-04-10?min_connection=60&max_connection=120"
"/results/BRI/paris/out/2026-04-10?min_connection=60"
)
html = resp.get_data(as_text=True)
@ -594,7 +632,7 @@ def test_results_shows_eurostar_price_and_total(monkeypatch: Any) -> None:
client = _client()
resp = client.get(
"/results/BRI/paris/out/2026-04-10?min_connection=60&max_connection=120"
"/results/BRI/paris/out/2026-04-10?min_connection=60"
)
html = resp.get_data(as_text=True)
@ -651,7 +689,7 @@ def test_results_uses_unique_row_keys_for_same_eurostar(monkeypatch: Any) -> Non
client = _client()
resp = client.get(
"/results/BRI/paris/out/2026-04-10?min_connection=60&max_connection=120"
"/results/BRI/paris/out/2026-04-10?min_connection=60"
)
html = resp.get_data(as_text=True)
@ -696,7 +734,7 @@ def test_results_shows_unreachable_service_when_no_trips(monkeypatch: Any) -> No
client = _client()
resp = client.get(
"/results/BRI/paris/out/2026-04-10?min_connection=60&max_connection=120"
"/results/BRI/paris/out/2026-04-10?min_connection=60"
)
html = resp.get_data(as_text=True)
@ -714,7 +752,7 @@ def test_results_shows_eurostar_plus_price(monkeypatch: Any) -> None:
client = _client()
resp = client.get(
"/results/BRI/paris/out/2026-04-10?min_connection=60&max_connection=120"
"/results/BRI/paris/out/2026-04-10?min_connection=60"
)
html = resp.get_data(as_text=True)
@ -729,7 +767,7 @@ def test_results_selectors_present(monkeypatch: Any) -> None:
client = _client()
resp = client.get(
"/results/BRI/paris/out/2026-04-10?min_connection=60&max_connection=120"
"/results/BRI/paris/out/2026-04-10?min_connection=60"
)
html = resp.get_data(as_text=True)
@ -786,7 +824,7 @@ def test_results_preloads_cached_advance_fares(monkeypatch: Any) -> None:
client = _client()
resp = client.get(
"/results/BRI/paris/out/2026-04-10?min_connection=60&max_connection=120"
"/results/BRI/paris/out/2026-04-10?min_connection=60"
)
html = resp.get_data(as_text=True)