diff --git a/validate_yaml.py b/validate_yaml.py index 818840d..4e3ed1d 100755 --- a/validate_yaml.py +++ b/validate_yaml.py @@ -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")