Include UK bank holidays on international trips

This commit is contained in:
Edward Betts 2026-08-31 16:18:03 +01:00
parent 82023e16b3
commit 645957288d
2 changed files with 43 additions and 1 deletions

View file

@ -17,7 +17,7 @@ def get_trip_holidays(trip: Trip) -> list[Holiday]:
"""Get holidays happening during trip."""
if not trip.end:
return []
countries = {c.alpha_2 for c in trip.countries}
countries = {"GB", *(c.alpha_2 for c in trip.countries)}
return sorted(
(
hol

42
tests/test_holidays.py Normal file
View file

@ -0,0 +1,42 @@
"""Tests for holiday selection."""
from datetime import date
from unittest import mock
import flask
import agenda.holidays
from agenda.types import Holiday, Trip
def test_trip_holidays_include_uk_bank_holiday_for_international_trip() -> None:
"""UK bank holidays remain relevant while travelling internationally."""
trip = Trip(
start=date(2026, 8, 23),
accommodation=[
{
"name": "Paris hotel",
"location": "Paris",
"country": "fr",
"from": date(2026, 8, 23),
"to": date(2026, 8, 31),
}
],
)
summer_bank_holiday = Holiday(
date=date(2026, 8, 31),
name="Summer bank holiday",
country="gb",
)
app = flask.Flask(__name__)
app.config["DATA_DIR"] = "/unused"
with (
app.app_context(),
mock.patch.object(
agenda.holidays,
"get_all",
return_value=[summer_bank_holiday],
),
):
assert agenda.holidays.get_trip_holidays(trip) == [summer_bank_holiday]