mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-27 14:57:41 +00:00
More tests
This commit is contained in:
parent
9c265a8bc1
commit
1018ed6da6
2 changed files with 44 additions and 15 deletions
|
|
@ -16,9 +16,10 @@ import random
|
||||||
class StorageTests(object):
|
class StorageTests(object):
|
||||||
item_template = u'UID:{uid}\nX-SOMETHING:{r}'
|
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()
|
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):
|
def _get_storage(self, **kwargs):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
|
||||||
|
|
@ -15,20 +15,48 @@ from vdirsyncer.storage.dav.caldav import CaldavStorage
|
||||||
from . import DavStorageTests
|
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):
|
class CaldavStorageTests(TestCase, DavStorageTests):
|
||||||
storage_class = CaldavStorage
|
storage_class = CaldavStorage
|
||||||
radicale_path = '/bob/test.ics/'
|
radicale_path = '/bob/test.ics/'
|
||||||
|
|
||||||
item_template = (u'BEGIN:VCALENDAR\n'
|
item_template = TASK_TEMPLATE
|
||||||
u'VERSION:2.0\n'
|
|
||||||
u'PRODID:-//dmfs.org//mimedir.icalendar//EN\n'
|
def test_both_vtodo_and_vevent(self):
|
||||||
u'BEGIN:VTODO\n'
|
task = self._create_bogus_item(1, item_template=TASK_TEMPLATE)
|
||||||
u'CREATED:20130721T142233Z\n'
|
event = self._create_bogus_item(2, item_template=EVENT_TEMPLATE)
|
||||||
u'DTSTAMP:20130730T074543Z\n'
|
s = self._get_storage()
|
||||||
u'LAST-MODIFIED;VALUE=DATE-TIME:20140122T151338Z\n'
|
href_etag_task = s.upload(task)
|
||||||
u'SEQUENCE:2\n'
|
href_etag_event = s.upload(event)
|
||||||
u'SUMMARY:Book: Kowlani - Tödlicher Staub\n'
|
assert set(s.list()) == set([
|
||||||
u'UID:{uid}\n'
|
href_etag_task,
|
||||||
u'X-SOMETHING:{r}\n'
|
href_etag_event
|
||||||
u'END:VTODO\n'
|
])
|
||||||
u'END:VCALENDAR')
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue