Check flight bookings are in chronological order.

This commit is contained in:
Edward Betts 2024-12-08 14:12:36 +00:00
parent 9a204d8526
commit f6d715e52a

View file

@ -43,14 +43,20 @@ def check_trips() -> None:
def check_flights(airlines: set[str]) -> None:
"""Check flights."""
"""Check flights and ensure they are in chronological order."""
bookings = agenda.travel.parse_yaml("flights", data_dir)
prev_first_depart = None
for booking in bookings:
assert all(flight["airline"] in airlines for flight in booking["flights"])
for booking in bookings:
check_currency(booking)
if prev_first_depart:
assert (
booking["flights"][0]["depart"] > prev_first_depart
), "Bookings are not in chronological order by first flight's departure."
prev_first_depart = booking["flights"][0]["depart"]
print(len(bookings), "flights")