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
91a284d60b
commit
9c417248de
3 changed files with 57 additions and 2 deletions
|
|
@ -62,6 +62,28 @@ PRODID:-//hacksw/handcal//NONSGML v1.0//EN
|
||||||
''' + BARE_EVENT_TEMPLATE + u'''
|
''' + BARE_EVENT_TEMPLATE + u'''
|
||||||
END:VCALENDAR'''
|
END:VCALENDAR'''
|
||||||
|
|
||||||
|
EVENT_WITH_TIMEZONE_TEMPLATE = '''BEGIN:VCALENDAR
|
||||||
|
BEGIN:VTIMEZONE
|
||||||
|
TZID:Europe/Rome
|
||||||
|
X-LIC-LOCATION:Europe/Rome
|
||||||
|
BEGIN:DAYLIGHT
|
||||||
|
TZOFFSETFROM:+0100
|
||||||
|
TZOFFSETTO:+0200
|
||||||
|
TZNAME:CEST
|
||||||
|
DTSTART:19700329T020000
|
||||||
|
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3
|
||||||
|
END:DAYLIGHT
|
||||||
|
BEGIN:STANDARD
|
||||||
|
TZOFFSETFROM:+0200
|
||||||
|
TZOFFSETTO:+0100
|
||||||
|
TZNAME:CET
|
||||||
|
DTSTART:19701025T030000
|
||||||
|
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
|
||||||
|
END:STANDARD
|
||||||
|
END:VTIMEZONE
|
||||||
|
''' + BARE_EVENT_TEMPLATE + '''
|
||||||
|
END:VCALENDAR'''
|
||||||
|
|
||||||
|
|
||||||
SIMPLE_TEMPLATE = u'''BEGIN:FOO
|
SIMPLE_TEMPLATE = u'''BEGIN:FOO
|
||||||
UID:{uid}
|
UID:{uid}
|
||||||
|
|
|
||||||
14
tests/unit/test_exceptions.py
Normal file
14
tests/unit/test_exceptions.py
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
from vdirsyncer import exceptions
|
||||||
|
|
||||||
|
|
||||||
|
def test_user_error_problems():
|
||||||
|
e = exceptions.UserError('A few problems occured', problems=[
|
||||||
|
'Problem one',
|
||||||
|
'Problem two',
|
||||||
|
'Problem three'
|
||||||
|
])
|
||||||
|
|
||||||
|
assert 'one' in str(e)
|
||||||
|
assert 'two' in str(e)
|
||||||
|
assert 'three' in str(e)
|
||||||
|
assert 'problems occured' in str(e)
|
||||||
|
|
@ -2,8 +2,14 @@
|
||||||
|
|
||||||
from textwrap import dedent
|
from textwrap import dedent
|
||||||
|
|
||||||
from tests import BARE_EVENT_TEMPLATE, EVENT_TEMPLATE, VCARD_TEMPLATE, \
|
import hypothesis.strategies as st
|
||||||
normalize_item
|
from hypothesis import given
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from tests import BARE_EVENT_TEMPLATE, EVENT_TEMPLATE, \
|
||||||
|
EVENT_WITH_TIMEZONE_TEMPLATE, VCARD_TEMPLATE, normalize_item, \
|
||||||
|
uid_strategy
|
||||||
|
|
||||||
import vdirsyncer.utils.vobject as vobject
|
import vdirsyncer.utils.vobject as vobject
|
||||||
|
|
||||||
|
|
@ -195,3 +201,16 @@ def test_multiline_uid_complex():
|
||||||
assert vobject.Item(a).uid == (u'040000008200E00074C5B7101A82E008000000005'
|
assert vobject.Item(a).uid == (u'040000008200E00074C5B7101A82E008000000005'
|
||||||
u'0AAABEEF50DCF001000000062548482FA830A46B9'
|
u'0AAABEEF50DCF001000000062548482FA830A46B9'
|
||||||
u'EA62114AC9F0EF')
|
u'EA62114AC9F0EF')
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('template', [EVENT_TEMPLATE,
|
||||||
|
EVENT_WITH_TIMEZONE_TEMPLATE,
|
||||||
|
VCARD_TEMPLATE])
|
||||||
|
@given(uid=st.one_of(st.none(), uid_strategy))
|
||||||
|
def test_replace_uid(template, uid):
|
||||||
|
item = vobject.Item(template.format(r=123, uid=123)).with_uid(uid)
|
||||||
|
assert item.uid == uid
|
||||||
|
if uid:
|
||||||
|
assert item.raw.count('\nUID:{}'.format(uid)) == 1
|
||||||
|
else:
|
||||||
|
assert '\nUID:' not in item.raw
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue