Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/+alarm-x-properties.bugfix.rst
Original file line number Diff line number Diff line change
@@ -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``.
8 changes: 6 additions & 2 deletions src/calendaring/_corpus.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions tests/_async/test_memory_conformance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"):
Expand Down Expand Up @@ -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),
Expand Down
19 changes: 19 additions & 0 deletions tests/_sync/test_memory_conformance.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading