From 8c225f019c0ae6baa48a0b9901f27e4b35c9488c Mon Sep 17 00:00:00 2001 From: Guillaume Ayoub Date: Thu, 7 Jul 2016 17:49:56 +0200 Subject: [PATCH] Fix support of recurring events --- radicale/storage.py | 3 ++- tests/static/event2.ics | 10 ++++++++++ tests/test_base.py | 14 ++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/radicale/storage.py b/radicale/storage.py index 79d5edc..c50edf5 100644 --- a/radicale/storage.py +++ b/radicale/storage.py @@ -527,7 +527,8 @@ class Collection(BaseCollection): for item in items: for content in ("vevent", "vtodo", "vjournal"): if content in item.contents: - collection.add(getattr(item, content)) + for item_part in getattr(item, "%s_list" % content): + collection.add(item_part) break return collection.serialize() elif self.get_meta("tag") == "VADDRESSBOOK": diff --git a/tests/static/event2.ics b/tests/static/event2.ics index 2844312..8695944 100644 --- a/tests/static/event2.ics +++ b/tests/static/event2.ics @@ -28,5 +28,15 @@ SUMMARY:Event2 DTSTART;TZID=Europe/Paris:20130902T180000 DTEND;TZID=Europe/Paris:20130902T190000 RRULE:FREQ=WEEKLY +SEQUENCE:1 +END:VEVENT +BEGIN:VEVENT +DTSTART;TZID=Europe/Paris:20130910T170000 +DTEND;TZID=Europe/Paris:20130910T180000 +DTSTAMP:20140902T150158Z +SUMMARY:Event2 +UID:event2 +RECURRENCE-ID;TZID=Europe/Paris:20130909T180000 +SEQUENCE:2 END:VEVENT END:VCALENDAR diff --git a/tests/test_base.py b/tests/test_base.py index ed88568..5fd3ba7 100644 --- a/tests/test_base.py +++ b/tests/test_base.py @@ -97,6 +97,20 @@ class BaseRequests: status, headers, answer = self.request("GET", "/calendar.ics/") assert "VEVENT" not in answer + def test_multiple_events_with_same_uid(self): + """Add two events with the same UID.""" + self.request("MKCOL", "/calendar.ics/") + self.request("PUT", "/calendar.ics/", get_file_content("event2.ics")) + status, headers, answer = self.request( + "REPORT", "/calendar.ics/", + """ + + + """) + assert answer.count("") == 1 + status, headers, answer = self.request("GET", "/calendar.ics/") + assert answer.count("BEGIN:VEVENT") == 2 + def _test_filter(self, filters, kind="event", items=1): filters_text = "".join( "%s" % filter_ for filter_ in filters)