From b32f3ef3e15cd5edacca0ddaa9240c3814bc88ad Mon Sep 17 00:00:00 2001 From: Tobias Brox Date: Tue, 30 Nov 2021 14:50:21 +0100 Subject: potential fix and test code for https://github.com/python-caldav/caldav/issues/155 --- caldav/objects.py | 2 +- tests/test_caldav.py | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/caldav/objects.py b/caldav/objects.py index 8ebf2fa..91f4af9 100644 --- a/caldav/objects.py +++ b/caldav/objects.py @@ -594,7 +594,7 @@ class Calendar(DAVObject): obj.save() def _use_or_create_ics(self, ical, objtype, **ical_data): - if ical_data or ((isinstance(ical, str) or isinstance(ical, bytes)) and not b'BEGIN:V' in to_wire(ical)): + if ical_data or ((isinstance(ical, str) or isinstance(ical, bytes)) and not b'BEGIN:VCALENDAR' in to_wire(ical)): return vcal.create_ical(ical_fragment=ical, objtype=objtype, **ical_data) return ical diff --git a/tests/test_caldav.py b/tests/test_caldav.py index 7edd5b8..c0979b0 100644 --- a/tests/test_caldav.py +++ b/tests/test_caldav.py @@ -73,6 +73,15 @@ END:VEVENT END:VCALENDAR """ +broken_ev1 = """BEGIN:VEVENT +UID:20010712T182145Z-123401@example.com +DTSTAMP:20060712T182145Z +DTSTART:20060714T170000Z +DTEND:20060715T040000Z +SUMMARY:Bastille Day Party +END:VEVENT +""" + ev2 = """BEGIN:VCALENDAR VERSION:2.0 PRODID:-//Example Corp.//CalDAV Client//EN @@ -666,7 +675,7 @@ class RepeatedFunctionalTestsBaseClass(object): assert_equal(len(existing_events), 0) # add event - c.save_event(ev1) + c.save_event(broken_ev1) # c.events() should give a full list of events events = c.events() -- cgit v1.2.3