More validation

This commit is contained in:
Edward Betts 2025-01-30 13:34:57 +00:00
parent 24c3242189
commit 6444229694

View file

@ -46,9 +46,17 @@ def check_flights(airlines: set[str]) -> None:
"""Check flights and ensure they are in chronological order.""" """Check flights and ensure they are in chronological order."""
bookings = agenda.travel.parse_yaml("flights", data_dir) bookings = agenda.travel.parse_yaml("flights", data_dir)
flight_count = 0
co2_flight_count = 0
prev_first_depart = None prev_first_depart = None
for booking in bookings: for booking in bookings:
if "trip" not in booking:
pprint(booking)
assert "trip" in booking
assert all(flight["airline"] in airlines for flight in booking["flights"]) assert all(flight["airline"] in airlines for flight in booking["flights"])
flight_count += len(booking["flights"])
co2_flight_count += len([flight for flight in booking["flights"] if "co2_kg" in flight])
check_currency(booking) check_currency(booking)
if prev_first_depart: if prev_first_depart:
@ -57,7 +65,8 @@ def check_flights(airlines: set[str]) -> None:
), "Bookings are not in chronological order by first flight's departure." ), "Bookings are not in chronological order by first flight's departure."
prev_first_depart = booking["flights"][0]["depart"] prev_first_depart = booking["flights"][0]["depart"]
print(len(bookings), "flights") print(f"{len(bookings)} flight bookings, {flight_count} flights, "
f"{co2_flight_count} with CO2 numbers")
def check_trains() -> None: def check_trains() -> None: