Show home marker for car journeys

This commit is contained in:
Edward Betts 2026-07-09 10:10:17 +01:00
parent 086bc630c9
commit 1e9169b740
3 changed files with 56 additions and 5 deletions

View file

@ -171,8 +171,10 @@ def test_get_trip_routes_assumes_unbooked_paris_trip_is_by_train(
]
def test_load_cars_infers_route_labels_and_home_marker(tmp_path: pathlib.Path) -> None:
"""Car journeys should load direct GeoJSON routes and endpoint markers."""
def test_load_cars_infers_route_labels_and_home_marker(
tmp_path: pathlib.Path,
) -> None:
"""Car journeys should load direct GeoJSON routes and home endpoint markers."""
(tmp_path / "car_routes").mkdir()
(tmp_path / "car_journeys.yaml").write_text("""---
- trip: 2026-07-16
@ -201,6 +203,40 @@ def test_load_cars_infers_route_labels_and_home_marker(tmp_path: pathlib.Path) -
assert cars[0]["to"] == "EMF"
assert cars[0]["geojson_filename"] == "PCH_to_EMF"
assert cars[0]["distance"] > 0
assert cars[0]["from_location"] == {
"name": "PCH",
"type": "home",
"latitude": 51.44083,
"longitude": -2.60283,
}
assert "to_location" not in cars[0]
def test_load_cars_can_show_endpoint_markers(tmp_path: pathlib.Path) -> None:
"""Car endpoint markers should be opt-in."""
(tmp_path / "car_routes").mkdir()
(tmp_path / "car_journeys.yaml").write_text("""---
- trip: 2026-07-16
depart: 2026-07-16
arrive: 2026-07-16
route: PCH_to_EMF.geojson
show_markers: true
""")
(tmp_path / "car_routes" / "PCH_to_EMF.geojson").write_text(
json.dumps(
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "LineString",
"coordinates": [[-2.60283, 51.44083], [-1.2, 52.0]],
},
}
)
)
cars = agenda.trip.load_cars(str(tmp_path))
assert cars[0]["from_location"] == {
"name": "PCH",
"type": "home",