"""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"