# SPDX-License-Identifier: GPL-3.0-or-later # Copyright (C) 2026 kawaiipunk from __future__ import annotations from datetime import datetime, timezone from pathlib import Path from sigcal_bot.expand import parse_events FIXTURE = Path(__file__).parent / "fixtures" / "tec-like.ics.txt" def load_bytes() -> bytes: return FIXTURE.read_bytes() def test_parses_tec_style_feed(): events = parse_events( load_bytes(), datetime(2026, 11, 19, tzinfo=timezone.utc), datetime(2026, 12, 1, tzinfo=timezone.utc), "Europe/London", ) assert len(events) == 3 first, all_day, third = events assert first.summary == "Clean up Greater Manchester Pension fund" assert first.series_id == "tec:1839" assert not first.all_day assert first.image_url.endswith("inbound5975249048432321891.png") assert first.url.endswith("clean-up-greater-manchester-pension-fund/") # 09:00 London on 20 Nov 2026 is GMT (UTC). assert first.start == datetime(2026, 11, 20, 9, 0, tzinfo=timezone.utc) assert all_day.all_day assert all_day.series_id == "tec:1902" assert all_day.start == datetime(2026, 11, 21, 0, 0, tzinfo=timezone.utc) assert third.series_id == "tec:1839" assert third.image_url.endswith("poster.webp") def test_window_excludes_far_future(): events = parse_events( load_bytes(), datetime(2026, 11, 19, tzinfo=timezone.utc), datetime(2026, 11, 20, tzinfo=timezone.utc), "Europe/London", ) assert len(events) <= 1