Show all valid Eurostar connections
This commit is contained in:
parent
5272956050
commit
c9aad7ad4c
2 changed files with 28 additions and 8 deletions
|
|
@ -128,11 +128,11 @@ def test_max_connection_enforced() -> None:
|
|||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Only earliest valid Eurostar per GWR departure
|
||||
# All valid Eurostars per National Rail departure
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
def test_only_earliest_eurostar_per_gwr() -> None:
|
||||
def test_all_valid_eurostars_per_gwr() -> None:
|
||||
es1 = {
|
||||
"depart_st_pancras": "10:01",
|
||||
"arrive_destination": "13:34",
|
||||
|
|
@ -143,9 +143,8 @@ def test_only_earliest_eurostar_per_gwr() -> None:
|
|||
"arrive_destination": "14:34",
|
||||
"destination": "Paris Gare du Nord",
|
||||
}
|
||||
trips = combine_trips([GWR_FAST], [es1, es2], DATE)
|
||||
assert len(trips) == 1
|
||||
assert trips[0]["depart_st_pancras"] == "10:01"
|
||||
trips = combine_trips([GWR_FAST], [es1, es2], DATE, max_connection_minutes=140)
|
||||
assert [t["depart_st_pancras"] for t in trips] == ["10:01", "11:01"]
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
|
@ -295,3 +294,27 @@ def test_combine_inbound_trips_pairs_eurostar_to_paddington_departure() -> None:
|
|||
assert trips[0]["arrive_uk_station"] == "18:55"
|
||||
assert trips[0]["ticket_price"] == 63.60
|
||||
assert trips[0]["check_in_by"] == "14:42"
|
||||
|
||||
|
||||
def test_combine_inbound_trips_keeps_all_valid_paddington_departures() -> None:
|
||||
eurostar = [
|
||||
{
|
||||
"depart_destination": "15:12",
|
||||
"arrive_st_pancras": "16:30",
|
||||
"destination": "Paris Gare du Nord",
|
||||
}
|
||||
]
|
||||
gwr = [
|
||||
{"depart_paddington": "17:15", "arrive_destination": "18:55"},
|
||||
{"depart_paddington": "17:45", "arrive_destination": "19:25"},
|
||||
]
|
||||
|
||||
trips = combine_inbound_trips(
|
||||
eurostar,
|
||||
gwr,
|
||||
DATE,
|
||||
min_connection_minutes=30,
|
||||
max_connection_minutes=120,
|
||||
)
|
||||
|
||||
assert [t["depart_paddington"] for t in trips] == ["17:15", "17:45"]
|
||||
|
|
|
|||
|
|
@ -179,7 +179,6 @@ def combine_trips(
|
|||
trips = []
|
||||
|
||||
for gwr in gwr_trains:
|
||||
# Find only the earliest viable Eurostar for this GWR departure
|
||||
for es in eurostar_trains:
|
||||
connection = _is_viable_connection(
|
||||
gwr,
|
||||
|
|
@ -223,7 +222,6 @@ def combine_trips(
|
|||
"ticket_code": fare["code"] if fare else None,
|
||||
}
|
||||
)
|
||||
break # Only the earliest valid Eurostar per GWR departure
|
||||
|
||||
trips.sort(key=lambda t: (t["depart_bristol"], t["depart_st_pancras"]))
|
||||
return trips
|
||||
|
|
@ -289,7 +287,6 @@ def combine_inbound_trips(
|
|||
"ticket_code": fare["code"] if fare else None,
|
||||
}
|
||||
)
|
||||
break
|
||||
|
||||
trips.sort(key=lambda t: (t["depart_destination"], t["depart_paddington"]))
|
||||
return trips
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue