Add app route tests and fix stale assertions

This commit is contained in:
Edward Betts 2026-04-01 14:33:10 +01:00
parent 143887d482
commit 4de4c1d556
3 changed files with 80 additions and 5 deletions

View file

@ -71,8 +71,8 @@ def test_min_connection_enforced():
# ES at 09:59 should be excluded, 10:00 should be included
es_too_close = {'depart_st_pancras': '09:59', 'arrive_destination': '13:00', 'destination': 'Paris Gare du Nord'}
es_ok = {'depart_st_pancras': '10:00', 'arrive_destination': '13:00', 'destination': 'Paris Gare du Nord'}
assert combine_trips([GWR_FAST], [es_too_close], DATE) == []
trips = combine_trips([GWR_FAST], [es_ok], DATE)
assert combine_trips([GWR_FAST], [es_too_close], DATE, min_connection_minutes=75) == []
trips = combine_trips([GWR_FAST], [es_ok], DATE, min_connection_minutes=75)
assert len(trips) == 1
@ -80,9 +80,9 @@ def test_max_connection_enforced():
# Arrive Paddington 08:45, max 140 min → latest St Pancras 11:05
es_ok = {'depart_st_pancras': '11:05', 'arrive_destination': '14:00', 'destination': 'Paris Gare du Nord'}
es_too_late = {'depart_st_pancras': '11:06', 'arrive_destination': '14:00', 'destination': 'Paris Gare du Nord'}
trips = combine_trips([GWR_FAST], [es_ok], DATE)
trips = combine_trips([GWR_FAST], [es_ok], DATE, max_connection_minutes=140)
assert len(trips) == 1
assert combine_trips([GWR_FAST], [es_too_late], DATE) == []
assert combine_trips([GWR_FAST], [es_too_late], DATE, max_connection_minutes=140) == []
# ---------------------------------------------------------------------------
@ -104,7 +104,7 @@ def test_only_earliest_eurostar_per_gwr():
def test_multiple_gwr_trains():
gwr2 = {'depart_bristol': '08:00', 'arrive_paddington': '09:45'}
es = {'depart_st_pancras': '11:01', 'arrive_destination': '14:34', 'destination': 'Paris Gare du Nord'}
trips = combine_trips([GWR_FAST, gwr2], [es], DATE)
trips = combine_trips([GWR_FAST, gwr2], [es], DATE, max_connection_minutes=140)
assert len(trips) == 2
assert trips[0]['depart_bristol'] == '07:00'
assert trips[1]['depart_bristol'] == '08:00'