"""Results compared with real calendars. Every expected value below comes from a source outside this service, mostly the law that defines the holidays. When a test here fails after a library update, check the source first: the law may have changed, not the code. Sources: - CZ: zakon c. 245/2000 Sb., o statnich svatcich, ve zneni od roku 2016 (Velky patek). Fond pracovni doby 2026 je 250 dnu. - DE: Feiertagsgesetze der Lander, Bayern: Fronleichnam celostatne v BY, Maria Himmelfahrt jen v obcich s prevahou katoliku. - AT: Feiertagsruhegesetz 1957. - FR: Code du travail L3133-1, Alsasko a Mosela navic Vendredi saint a 26.12. - PL: ustawa o dniach wolnych od pracy, Wigilia 24.12 od roku 2025. - SK: zakon c. 241/1993 Z. z. - XECB: kalendar TARGET2 Evropske centralni banky. """ from __future__ import annotations from datetime import date from app.services.calendars import holidays_in_year, resolve_calendar from app.services.workdays import WorkCalendar, add_workdays, count_workdays def calendar_for(kind="country", code="CZ", region=None, categories=None, language="cs") -> WorkCalendar: info = resolve_calendar(kind, code, region, categories, language) return WorkCalendar( weekend=info.default_weekend, min_date=info.min_date, max_date=info.max_date, holidays_in_year=lambda year: holidays_in_year(info.spec, year), ) def holiday_dates(kind="country", code="CZ", region=None, categories=None, year=2026) -> set[date]: info = resolve_calendar(kind, code, region, categories, None) return set(holidays_in_year(info.spec, year)) # Czechia CZ_2026 = { date(2026, 1, 1), date(2026, 4, 3), date(2026, 4, 6), date(2026, 5, 1), date(2026, 5, 8), date(2026, 7, 5), date(2026, 7, 6), date(2026, 9, 28), date(2026, 10, 28), date(2026, 11, 17), date(2026, 12, 24), date(2026, 12, 25), date(2026, 12, 26), } def test_cz_2026_holidays_exactly_match_law(): assert holiday_dates(code="CZ", year=2026) == CZ_2026 def test_cz_2027_easter(): dates = holiday_dates(code="CZ", year=2027) assert date(2027, 3, 26) in dates assert date(2027, 3, 29) in dates def test_cz_working_time_fund_2026(): calendar = calendar_for() assert count_workdays(calendar, date(2026, 1, 1), date(2026, 12, 31)).workdays == 250 def test_cz_example_from_assignment(): assert add_workdays(calendar_for(), date(2026, 11, 26), 3).result == date(2026, 12, 1) def test_cz_over_christmas(): assert add_workdays(calendar_for(), date(2026, 12, 23), 1).result == date(2026, 12, 28) def test_cz_over_easter(): assert add_workdays(calendar_for(), date(2026, 4, 2), 1).result == date(2026, 4, 7) def test_cz_backwards_over_may_holidays(): assert add_workdays(calendar_for(), date(2026, 5, 11), -1).result == date(2026, 5, 7) def test_cz_names_in_czech(): info = resolve_calendar("country", "CZ", None, None, "cs") names = holidays_in_year(info.spec, 2026)[date(2026, 12, 24)] assert names == ("Štědrý den",) # Germany def test_de_corpus_christi_only_in_region(): assert date(2026, 6, 4) not in holiday_dates(code="DE") assert date(2026, 6, 4) in holiday_dates(code="DE", region="BY") def test_de_region_by_name(): assert date(2026, 6, 4) in holiday_dates(code="DE", region="Bayern") def test_de_assumption_is_catholic_category_in_bavaria(): assert date(2026, 8, 15) not in holiday_dates(code="DE", region="BY") assert date(2026, 8, 15) in holiday_dates(code="DE", region="BY", categories=("public", "catholic")) def test_de_unity_day(): assert date(2026, 10, 3) in holiday_dates(code="DE") # Other EU countries def test_at_national_day_and_immaculate_conception(): dates = holiday_dates(code="AT") assert date(2026, 10, 26) in dates assert date(2026, 12, 8) in dates def test_fr_alsace_moselle(): assert date(2026, 12, 26) not in holiday_dates(code="FR") assert date(2026, 12, 26) in holiday_dates(code="FR", region="57") assert date(2026, 4, 3) in holiday_dates(code="FR", region="57") def test_pl_christmas_eve_since_2025(): assert date(2024, 12, 24) not in holiday_dates(code="PL", year=2024) assert date(2026, 12, 24) in holiday_dates(code="PL", year=2026) def test_sk_constitution_and_uprising(): dates = holiday_dates(code="SK") assert date(2026, 8, 29) in dates assert date(2026, 7, 5) in dates def test_every_eu_country_has_holidays_in_2026(): from app.services.calendars import EU_MEMBERS for code in EU_MEMBERS: assert len(holiday_dates(code=code)) >= 8, code # Financial calendar def test_target2_2026(): assert holiday_dates(kind="market", code="XECB") == { date(2026, 1, 1), date(2026, 4, 3), date(2026, 4, 6), date(2026, 5, 1), date(2026, 12, 25), date(2026, 12, 26), }