Files
sigcal/tests/test_expand.py
T
kawaiipunk 68cd2895e8 License under GPL-3.0-or-later
- add verbatim GPLv3 text as LICENSE
- declare license and license-files in pyproject
- add SPDX headers to Python sources
- document licensing in README
2026-11-18 16:48:51 +00:00

53 lines
1.5 KiB
Python

# 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 signal_cal_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