Initial signal-cal-bot skeleton: iCalendar feed to Signal group
- feed fetch with ETag/Last-Modified caching - iCalendar parsing/expansion with TEC series detection - posting-window scheduler with 3-day reminders and day-of fallback - image attachments from ATTACH, downscaled via Pillow - SQLite outbox with idempotent deliveries - watchdog alerts to Note to Self - Docker Compose with signal-cli-rest-api
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
|
||||
from calbot.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
|
||||
Reference in New Issue
Block a user