Add timeline car import and CO2 trip stats
This commit is contained in:
parent
38dbb2b4e7
commit
3747e83ade
14 changed files with 1038 additions and 29 deletions
|
|
@ -1,6 +1,6 @@
|
|||
"""Regression tests for trip page route wiring and rendering."""
|
||||
|
||||
from datetime import date, datetime
|
||||
from datetime import date, datetime, timedelta, timezone
|
||||
import typing
|
||||
from unittest import mock
|
||||
|
||||
|
|
@ -307,3 +307,57 @@ def test_trip_page_uses_bed_icon_for_overnight_train_coach() -> None:
|
|||
assert response.status_code == 200
|
||||
page = response.data.decode()
|
||||
assert "🛏️ Coach S, Seat 4" in page
|
||||
|
||||
|
||||
def test_trip_page_renders_car_times_in_local_route_timezone() -> None:
|
||||
"""Car journeys should display in the route's local timezone."""
|
||||
trip = Trip(
|
||||
start=date(2023, 8, 23),
|
||||
travel=[
|
||||
{
|
||||
"type": "car",
|
||||
"depart": datetime(
|
||||
2023, 8, 24, 5, 22, tzinfo=timezone(timedelta(hours=1))
|
||||
),
|
||||
"arrive": datetime(
|
||||
2023, 8, 24, 6, 26, tzinfo=timezone(timedelta(hours=1))
|
||||
),
|
||||
"from": "JFK",
|
||||
"to": "Rockaway",
|
||||
"distance": 102.0,
|
||||
"from_location": {
|
||||
"name": "JFK",
|
||||
"country": "us",
|
||||
"latitude": 40.64,
|
||||
"longitude": -73.78,
|
||||
},
|
||||
"to_location": {
|
||||
"name": "Rockaway",
|
||||
"country": "us",
|
||||
"latitude": 40.907,
|
||||
"longitude": -74.554,
|
||||
},
|
||||
}
|
||||
],
|
||||
)
|
||||
|
||||
with web_view.app.app_context():
|
||||
with (
|
||||
mock.patch.object(web_view, "get_trip_list", return_value=[trip]),
|
||||
mock.patch.object(agenda.weather, "get_trip_weather", return_value=[]),
|
||||
mock.patch.object(
|
||||
web_view,
|
||||
"_timezone_from_coordinates",
|
||||
return_value="America/New_York",
|
||||
),
|
||||
):
|
||||
web_view.app.config["TESTING"] = True
|
||||
|
||||
with web_view.app.test_client() as client:
|
||||
response = client.get("/trip/2023-08-23")
|
||||
|
||||
assert response.status_code == 200
|
||||
page = response.data.decode()
|
||||
assert "JFK → Rockaway" in page
|
||||
assert "00:22 → 01:26" in page
|
||||
assert "05:22 → 06:26" not in page
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue