Compare commits
No commits in common. "38792a1721dc11b907180adaa3cc5b9d1d87a769" and "ef624f83dd9d9ddc56f6d3e0b657248c283e9df1" have entirely different histories.
38792a1721
...
ef624f83dd
|
@ -29,12 +29,10 @@ def check_trips() -> None:
|
||||||
print(len(routes), "routes")
|
print(len(routes), "routes")
|
||||||
|
|
||||||
|
|
||||||
def check_flights(airlines: set[str]) -> None:
|
def check_flights() -> None:
|
||||||
"""Check flights."""
|
"""Check flights."""
|
||||||
bookings = agenda.travel.parse_yaml("flights", data_dir)
|
flights = agenda.travel.parse_yaml("flights", data_dir)
|
||||||
for booking in bookings:
|
print(len(flights), "flights")
|
||||||
assert all(flight["airline"] in airlines for flight in booking["flights"])
|
|
||||||
print(len(bookings), "flights")
|
|
||||||
|
|
||||||
|
|
||||||
def check_trains() -> None:
|
def check_trains() -> None:
|
||||||
|
@ -59,25 +57,31 @@ def check_events() -> None:
|
||||||
print(len(events), "events")
|
print(len(events), "events")
|
||||||
|
|
||||||
|
|
||||||
def check_coordinates(item: agenda.types.StrDict) -> None:
|
|
||||||
"""Check coordinate are valid."""
|
|
||||||
if "latitude" not in item and "longitude" not in item:
|
|
||||||
return
|
|
||||||
assert "latitude" in item and "longitude" in item
|
|
||||||
assert all(isinstance(item[key], (int, float)) for key in ("latitude", "longitude"))
|
|
||||||
|
|
||||||
|
|
||||||
def check_accommodation() -> None:
|
def check_accommodation() -> None:
|
||||||
"""Check accommodation."""
|
"""Check accommodation."""
|
||||||
filepath = os.path.join(data_dir, "accommodation.yaml")
|
filepath = os.path.join(data_dir, "accommodation.yaml")
|
||||||
accommodation_list = yaml.safe_load(open(filepath))
|
accommodation_list = yaml.safe_load(open(filepath))
|
||||||
|
|
||||||
required_fields = ["type", "name", "country", "location", "trip", "from", "to"]
|
|
||||||
|
|
||||||
for stay in accommodation_list:
|
for stay in accommodation_list:
|
||||||
try:
|
try:
|
||||||
assert all(field in stay for field in required_fields)
|
assert all(
|
||||||
check_coordinates(stay)
|
field in stay
|
||||||
|
for field in (
|
||||||
|
"type",
|
||||||
|
"name",
|
||||||
|
"country",
|
||||||
|
"location",
|
||||||
|
"trip",
|
||||||
|
"from",
|
||||||
|
"to",
|
||||||
|
)
|
||||||
|
)
|
||||||
|
if "latitude" in stay or "longitude" in stay:
|
||||||
|
assert "latitude" in stay and "longitude" in stay
|
||||||
|
assert all(
|
||||||
|
isinstance(stay[key], (int, float))
|
||||||
|
for key in ("latitude", "longitude")
|
||||||
|
)
|
||||||
except AssertionError:
|
except AssertionError:
|
||||||
pprint(stay)
|
pprint(stay)
|
||||||
raise
|
raise
|
||||||
|
@ -105,29 +109,25 @@ def check_stations() -> None:
|
||||||
assert agenda.get_country(station["country"])
|
assert agenda.get_country(station["country"])
|
||||||
|
|
||||||
|
|
||||||
def check_airlines() -> list[agenda.types.StrDict]:
|
def check_airlines() -> None:
|
||||||
"""Check airlines."""
|
"""Check airlines."""
|
||||||
airlines = agenda.travel.parse_yaml("airlines", data_dir)
|
airlines = agenda.travel.parse_yaml("airlines", data_dir)
|
||||||
print(len(airlines), "airlines")
|
print(len(airlines), "airlines")
|
||||||
for airline in airlines:
|
for airline in airlines:
|
||||||
assert airline.keys() == {"icao", "iata", "name"}
|
assert airline.keys() == {"icao", "iata", "name"}
|
||||||
assert len(airline["icao"]) == 3
|
|
||||||
assert len(airline["iata"]) == 2
|
|
||||||
|
|
||||||
return airlines
|
|
||||||
|
|
||||||
|
|
||||||
def check() -> None:
|
def check() -> None:
|
||||||
"""Validate personal data YAML files."""
|
"""Validate personal data YAML files."""
|
||||||
airlines = check_airlines()
|
|
||||||
check_trips()
|
check_trips()
|
||||||
check_flights({airline["iata"] for airline in airlines})
|
check_flights()
|
||||||
check_trains()
|
check_trains()
|
||||||
check_conferences()
|
check_conferences()
|
||||||
check_events()
|
check_events()
|
||||||
check_accommodation()
|
check_accommodation()
|
||||||
check_airports()
|
check_airports()
|
||||||
check_stations()
|
check_stations()
|
||||||
|
check_airlines()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Reference in a new issue