Weekend page now shows specific location (city and country) for each Saturday and Sunday based on travel history: - Analyzes flight arrivals and accommodation check-ins to determine exact location - Shows "home" when at Bristol, UK - Shows "City, 🏴 Country" format when traveling - Handles multi-location trips by finding most recent travel within trip period - Optimized to parse YAML files once instead of per-date lookup Closes #191 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
30 lines
1 KiB
Python
30 lines
1 KiB
Python
from datetime import date, datetime
|
|
|
|
import agenda.trip
|
|
from web_view import app
|
|
|
|
|
|
def test_get_location_for_date() -> None:
|
|
app.config["SERVER_NAME"] = "test"
|
|
with app.app_context():
|
|
today = datetime.now().date()
|
|
start = date(today.year, 1, 1)
|
|
trips = [
|
|
t for t in agenda.trip.build_trip_list() if t.start == date(2025, 2, 9)
|
|
]
|
|
assert len(trips) == 1
|
|
|
|
data_dir = app.config["PERSONAL_DATA"]
|
|
|
|
# Parse YAML files once for the test
|
|
import agenda.travel as travel
|
|
bookings = travel.parse_yaml("flights", data_dir)
|
|
accommodations = travel.parse_yaml("accommodation", data_dir)
|
|
airports = travel.parse_yaml("airports", data_dir)
|
|
|
|
l1 = agenda.busy.get_location_for_date(date(2025, 2, 15), trips, bookings, accommodations, airports)
|
|
assert l1[0] == "Hackettstown"
|
|
|
|
l2 = agenda.busy.get_location_for_date(date(2025, 7, 1), trips, bookings, accommodations, airports)
|
|
assert l2[0] == "Bristol"
|