Add travel booking and place import scripts
This commit is contained in:
parent
a87c9f993e
commit
5f6cb57c2a
10 changed files with 1177 additions and 3 deletions
|
|
@ -3,6 +3,7 @@
|
|||
from datetime import date
|
||||
|
||||
import agenda.trip
|
||||
import pytest
|
||||
from agenda.types import Trip
|
||||
from web_view import app
|
||||
|
||||
|
|
@ -101,3 +102,68 @@ def test_get_coordinates_and_routes_adds_unbooked_flight_airports() -> None:
|
|||
coord["name"] for coord in coordinates if coord["type"] == "airport"
|
||||
}
|
||||
assert airport_names == {"Heathrow Airport", "Paris Charles de Gaulle Airport"}
|
||||
|
||||
|
||||
def test_get_trip_routes_assumes_unbooked_paris_trip_is_by_train(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
"""Paris conferences without booked travel should show rail, not flight."""
|
||||
trip = Trip(
|
||||
start=date(2026, 7, 20),
|
||||
conferences=[
|
||||
{
|
||||
"name": "Paris Conf",
|
||||
"location": "Paris",
|
||||
"country": "fr",
|
||||
}
|
||||
],
|
||||
)
|
||||
stations = [
|
||||
{
|
||||
"name": "London St Pancras",
|
||||
"latitude": 51.531921,
|
||||
"longitude": -0.126361,
|
||||
"routes": {"Paris Gare du Nord": "London_St_Pancras_to_Paris_Gare_du_Nord"},
|
||||
},
|
||||
{
|
||||
"name": "Paris Gare du Nord",
|
||||
"latitude": 48.88111111111111,
|
||||
"longitude": 2.355277777777778,
|
||||
"routes": {"London St Pancras": "London_St_Pancras_to_Paris_Gare_du_Nord"},
|
||||
},
|
||||
]
|
||||
|
||||
def fake_parse_yaml(name: str, data_dir: str) -> object:
|
||||
if name == "stations":
|
||||
return stations
|
||||
if name == "airports":
|
||||
return {
|
||||
"LHR": {
|
||||
"name": "Heathrow Airport",
|
||||
"latitude": 51.47,
|
||||
"longitude": -0.45,
|
||||
},
|
||||
"CDG": {
|
||||
"name": "Paris Charles de Gaulle Airport",
|
||||
"city": "Paris",
|
||||
"country": "fr",
|
||||
"latitude": 49.01,
|
||||
"longitude": 2.55,
|
||||
},
|
||||
}
|
||||
raise AssertionError(f"unexpected YAML load: {name}")
|
||||
|
||||
monkeypatch.setattr(agenda.trip.travel, "parse_yaml", fake_parse_yaml)
|
||||
monkeypatch.setattr(
|
||||
agenda.trip, "load_flight_destination_rules", lambda _data_dir: []
|
||||
)
|
||||
|
||||
routes = agenda.trip.get_trip_routes(trip, "/tmp/personal-data")
|
||||
|
||||
assert routes == [
|
||||
{
|
||||
"type": "train",
|
||||
"key": "train_London St Pancras_Paris Gare du Nord",
|
||||
"geojson_filename": "train_routes/London_St_Pancras_to_Paris_Gare_du_Nord",
|
||||
}
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue