From 67aa23a90dd5ad079812d96d34cfe2a55cf648c9 Mon Sep 17 00:00:00 2001 From: Tobias Brox Date: Mon, 16 Nov 2026 21:51:56 +0100 Subject: [PATCH] test: X- properties on the corpus alarms The round-trip corpus carried X- properties on events, tasks and journals, but not on their alarms, so a backend dropping them from a VALARM passed the conformance suite. Both alarms now carry one, and a broken memory backend checks that the suite catches the loss. VTIMEZONE is left out on purpose: a server may replace it with its own, so verify does not compare it. Refs https://github.com/pycalendar/calendaring/issues/15 Prompts: > [pick from the task list: "calendaring: round-trip fixture corpus > for the conformance suite"] > come again? ... What X-properties? (the task was already done, except > for some small nit, I needed a bit of explaination to understand the > issue) > ok [add X- properties to VALARM and VTIMEZONE] Assisted-By: Claude Opus 5.5 Reviewed-by: Tobias Brox --- news/+alarm-x-properties.bugfix.rst | 1 + src/calendaring/_corpus.py | 8 ++++++-- tests/_async/test_memory_conformance.py | 19 +++++++++++++++++++ tests/_sync/test_memory_conformance.py | 19 +++++++++++++++++++ 4 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 news/+alarm-x-properties.bugfix.rst diff --git a/news/+alarm-x-properties.bugfix.rst b/news/+alarm-x-properties.bugfix.rst new file mode 100644 index 0000000..5b8a981 --- /dev/null +++ b/news/+alarm-x-properties.bugfix.rst @@ -0,0 +1 @@ +The conformance suite's round trip now also catches a backend that drops X- properties from an alarm: the corpus carries one on every ``VALARM``. diff --git a/src/calendaring/_corpus.py b/src/calendaring/_corpus.py index 7fea948..b05caf2 100644 --- a/src/calendaring/_corpus.py +++ b/src/calendaring/_corpus.py @@ -3,8 +3,10 @@ Each one carries what a backend is tempted to lose: time zones and their VTIMEZONE, floating times, dates, alarms, a recurrence set with EXDATE, RDATE and an override, escaped, multi-line and non-ASCII text, properties -with several values, and X- properties with parameters on every component -type. A backend may lose only what its declaration says it does. +with several values, and X- properties with parameters on every item and +alarm. Not on the VTIMEZONE: a server may replace it with its own, so verify +does not compare it, and the round trip checks only that every TZID has one. +A backend may lose only what its declaration says it does. """ from __future__ import annotations @@ -61,6 +63,7 @@ def _crlf(text: str) -> bytes: ACTION:DISPLAY DESCRIPTION:Møtet begynner snart TRIGGER:-PT15M +X-CONFORMANCE-ALARM;X-SNOOZE=PT5M:kept END:VALARM END:VEVENT BEGIN:VEVENT @@ -118,6 +121,7 @@ def _crlf(text: str) -> bytes: ACTION:DISPLAY DESCRIPTION:Fristen er i morgen TRIGGER;RELATED=END:-P1D +X-CONFORMANCE-ALARM;X-SNOOZE=PT1H:kept END:VALARM END:VTODO END:VCALENDAR diff --git a/tests/_async/test_memory_conformance.py b/tests/_async/test_memory_conformance.py index e736da5..60abdba 100644 --- a/tests/_async/test_memory_conformance.py +++ b/tests/_async/test_memory_conformance.py @@ -596,6 +596,18 @@ async def _create(self, calendar: icalendar.Calendar, *, native_id: str | None, return await super()._create(calendar, native_id=native_id, wire=None) +class DropsNestedXProperties(AsyncMemoryCollection): + """Keeps X- properties on the items, and drops them from their alarms.""" + + async def _create(self, calendar: icalendar.Calendar, *, native_id: str | None, wire: bytes | None) -> StoredObject: + calendar = copy.deepcopy(calendar) + for component in calendar.walk(): + if component.name == "VALARM": + for name in [n for n in component if n.startswith("X-")]: + del component[name] + return await super()._create(calendar, native_id=native_id, wire=None) + + class FirstValueOnly(Mangling): def mangle(self, component: icalendar.Component) -> None: for name in ("CATEGORIES", "ATTENDEE"): @@ -681,6 +693,13 @@ async def _time_entries( ), (DropsOverrides, "test_real_world_objects_round_trip", {"name": "event-series-in-a-time-zone"}, VerificationError), (FirstValueOnly, "test_real_world_objects_round_trip", {"name": "task-due-on-a-date"}, VerificationError), + ( + DropsNestedXProperties, + "test_real_world_objects_round_trip", + {"name": "event-series-in-a-time-zone"}, + VerificationError, + ), + (DropsNestedXProperties, "test_real_world_objects_round_trip", {"name": "task-due-on-a-date"}, VerificationError), (StartsInRange, "test_search_gives_the_client_side_answer", {"name": "events-in-range"}, ASSERTS), (StartsInRange, "test_search_gives_the_client_side_answer", {"name": "tasks-in-range"}, ASSERTS), (CompletesNothing, "test_complete_a_recurring_task", {}, ASSERTS), diff --git a/tests/_sync/test_memory_conformance.py b/tests/_sync/test_memory_conformance.py index e8a259d..9323a5f 100644 --- a/tests/_sync/test_memory_conformance.py +++ b/tests/_sync/test_memory_conformance.py @@ -596,6 +596,18 @@ def _create(self, calendar: icalendar.Calendar, *, native_id: str | None, wire: return super()._create(calendar, native_id=native_id, wire=None) +class DropsNestedXProperties(MemoryCollection): + """Keeps X- properties on the items, and drops them from their alarms.""" + + def _create(self, calendar: icalendar.Calendar, *, native_id: str | None, wire: bytes | None) -> StoredObject: + calendar = copy.deepcopy(calendar) + for component in calendar.walk(): + if component.name == "VALARM": + for name in [n for n in component if n.startswith("X-")]: + del component[name] + return super()._create(calendar, native_id=native_id, wire=None) + + class FirstValueOnly(Mangling): def mangle(self, component: icalendar.Component) -> None: for name in ("CATEGORIES", "ATTENDEE"): @@ -681,6 +693,13 @@ def _time_entries( ), (DropsOverrides, "test_real_world_objects_round_trip", {"name": "event-series-in-a-time-zone"}, VerificationError), (FirstValueOnly, "test_real_world_objects_round_trip", {"name": "task-due-on-a-date"}, VerificationError), + ( + DropsNestedXProperties, + "test_real_world_objects_round_trip", + {"name": "event-series-in-a-time-zone"}, + VerificationError, + ), + (DropsNestedXProperties, "test_real_world_objects_round_trip", {"name": "task-due-on-a-date"}, VerificationError), (StartsInRange, "test_search_gives_the_client_side_answer", {"name": "events-in-range"}, ASSERTS), (StartsInRange, "test_search_gives_the_client_side_answer", {"name": "tasks-in-range"}, ASSERTS), (CompletesNothing, "test_complete_a_recurring_task", {}, ASSERTS),