Files
sigcal/tests/test_expand.py
T
kawaiipunk 2b32c1a7f2 Rename project to signal-cal-bot
- package src/signal-cal-bot -> src/signal_cal_bot
- distribution and CLI entry point: signal-cal-bot
- env vars CALBOT_* -> SIGNAL_CAL_BOT_*
- database file, container names, user agents and logs renamed
- docs and compose updated
2026-11-18 16:45:54 +00:00

50 lines
1.4 KiB
Python

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