diff --git a/tests/storage/__init__.py b/tests/storage/__init__.py index d329c48..751c933 100644 --- a/tests/storage/__init__.py +++ b/tests/storage/__init__.py @@ -16,9 +16,10 @@ import random class StorageTests(object): item_template = u'UID:{uid}\nX-SOMETHING:{r}' - def _create_bogus_item(self, uid): + def _create_bogus_item(self, uid, item_template=None): r = random.random() - return Item(self.item_template.format(uid=uid, r=r)) + item_template = item_template or self.item_template + return Item(item_template.format(uid=uid, r=r)) def _get_storage(self, **kwargs): raise NotImplementedError() diff --git a/tests/storage/dav/test_caldav.py b/tests/storage/dav/test_caldav.py index 54a138a..ce9c713 100644 --- a/tests/storage/dav/test_caldav.py +++ b/tests/storage/dav/test_caldav.py @@ -15,20 +15,48 @@ from vdirsyncer.storage.dav.caldav import CaldavStorage from . import DavStorageTests +TASK_TEMPLATE = u'''BEGIN:VCALENDAR +VERSION:2.0 +PRODID:-//dmfs.org//mimedir.icalendar//EN +BEGIN:VTODO +CREATED:20130721T142233Z +DTSTAMP:20130730T074543Z +LAST-MODIFIED;VALUE=DATE-TIME:20140122T151338Z +SEQUENCE:2 +SUMMARY:Book: Kowlani - Tödlicher Staub +UID:{uid} +X-SOMETHING:{r} +END:VTODO +END:VCALENDAR''' + + +EVENT_TEMPLATE = u'''BEGIN:VCALENDAR +BEGIN:VCALENDAR +VERSION:2.0 +PRODID:-//hacksw/handcal//NONSGML v1.0//EN +BEGIN:VEVENT +DTSTART:19970714T170000Z +DTEND:19970715T035959Z +SUMMARY:Bastille Day Party +X-SOMETHING:{r} +UID:{uid} +END:VEVENT +END:VCALENDAR''' + + class CaldavStorageTests(TestCase, DavStorageTests): storage_class = CaldavStorage radicale_path = '/bob/test.ics/' - item_template = (u'BEGIN:VCALENDAR\n' - u'VERSION:2.0\n' - u'PRODID:-//dmfs.org//mimedir.icalendar//EN\n' - u'BEGIN:VTODO\n' - u'CREATED:20130721T142233Z\n' - u'DTSTAMP:20130730T074543Z\n' - u'LAST-MODIFIED;VALUE=DATE-TIME:20140122T151338Z\n' - u'SEQUENCE:2\n' - u'SUMMARY:Book: Kowlani - Tödlicher Staub\n' - u'UID:{uid}\n' - u'X-SOMETHING:{r}\n' - u'END:VTODO\n' - u'END:VCALENDAR') + item_template = TASK_TEMPLATE + + def test_both_vtodo_and_vevent(self): + task = self._create_bogus_item(1, item_template=TASK_TEMPLATE) + event = self._create_bogus_item(2, item_template=EVENT_TEMPLATE) + s = self._get_storage() + href_etag_task = s.upload(task) + href_etag_event = s.upload(event) + assert set(s.list()) == set([ + href_etag_task, + href_etag_event + ])