Fix trip map unbooked flight pins and timezone-safe busy date comparisons
This commit is contained in:
parent
f38c5327ea
commit
f9b79d5a51
3 changed files with 150 additions and 7 deletions
35
tests/test_busy_timezone.py
Normal file
35
tests/test_busy_timezone.py
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
"""Regression tests for timezone handling in busy location logic."""
|
||||
|
||||
from datetime import date, datetime, timezone
|
||||
|
||||
import agenda.busy
|
||||
from agenda.types import Trip
|
||||
|
||||
|
||||
def test_mixed_naive_and_aware_arrivals_do_not_crash() -> None:
|
||||
"""Most recent travel should compare mixed timezone styles safely."""
|
||||
trips = [
|
||||
Trip(
|
||||
start=date(2099, 12, 30),
|
||||
travel=[
|
||||
{
|
||||
"type": "flight",
|
||||
"arrive": datetime(2100, 1, 1, 10, 0, 0),
|
||||
"to": "CDG",
|
||||
"to_airport": {"country": "fr", "city": "Paris"},
|
||||
},
|
||||
{
|
||||
"type": "flight",
|
||||
"arrive": datetime(2100, 1, 1, 12, 0, 0, tzinfo=timezone.utc),
|
||||
"to": "AMS",
|
||||
"to_airport": {"country": "nl", "city": "Amsterdam"},
|
||||
},
|
||||
],
|
||||
)
|
||||
]
|
||||
|
||||
location = agenda.busy._find_most_recent_travel_before_date(date(2100, 1, 1), trips)
|
||||
assert location is not None
|
||||
assert location[0] == "Amsterdam"
|
||||
assert location[1] is not None
|
||||
assert location[1].alpha_2 == "NL"
|
||||
Loading…
Add table
Add a link
Reference in a new issue