Add return and inbound journey support

This commit is contained in:
Edward Betts 2026-05-21 08:46:35 +01:00
parent 6ba71447ef
commit 9691632f65
12 changed files with 1687 additions and 486 deletions

View file

@ -1,5 +1,10 @@
import pytest
from trip_planner import combine_trips, find_unreachable_morning_eurostars, _fmt_duration
from trip_planner import (
combine_inbound_trips,
combine_trips,
find_unreachable_morning_eurostars,
_fmt_duration,
)
DATE = '2026-03-30'
@ -178,3 +183,28 @@ def test_find_unreachable_eurostars_returns_empty_when_all_connectable():
]
assert find_unreachable_morning_eurostars(gwr, eurostar, DATE) == []
def test_combine_inbound_trips_pairs_eurostar_to_paddington_departure():
eurostar = [{
'depart_destination': '15:12',
'arrive_st_pancras': '16:30',
'destination': 'Paris Gare du Nord',
'train_number': 'ES 9035',
}]
gwr = [{
'depart_paddington': '17:15',
'arrive_destination': '18:55',
'headcode': '1B99',
}]
fares = {'17:15': {'ticket': 'Off-Peak Single', 'price': 63.60, 'code': 'SVS'}}
trips = combine_inbound_trips(eurostar, gwr, DATE, min_connection_minutes=30, max_connection_minutes=120, gwr_fares=fares)
assert len(trips) == 1
assert trips[0]['depart_destination'] == '15:12'
assert trips[0]['arrive_st_pancras'] == '16:30'
assert trips[0]['depart_paddington'] == '17:15'
assert trips[0]['arrive_uk_station'] == '18:55'
assert trips[0]['ticket_price'] == 63.60
assert trips[0]['check_in_by'] == '14:42'