summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Brox <tobias@redpill-linpro.com>2021-11-30 14:50:21 +0100
committerTobias Brox <tobias@redpill-linpro.com>2021-11-30 14:50:21 +0100
commitb32f3ef3e15cd5edacca0ddaa9240c3814bc88ad (patch)
tree77a4f45ce91a872e250411f9aa7f3acdf9bac94c
parenteb8b7f877f4c5ca6181a177431b4a57f0a8c2039 (diff)
downloadpython-caldav-b32f3ef3e15cd5edacca0ddaa9240c3814bc88ad.zip
potential fix and test code for https://github.com/python-caldav/caldav/issues/155
-rw-r--r--caldav/objects.py2
-rw-r--r--tests/test_caldav.py11
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()