mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-27 14:57:41 +00:00
Merge pull request #90 from untitaker/vcard_groups
Add tests for vcard groups
This commit is contained in:
commit
eb9253af94
2 changed files with 89 additions and 43 deletions
|
|
@ -1,6 +1,10 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
import pkg_resources
|
||||||
|
|
||||||
extensions = ['sphinx.ext.autodoc']
|
extensions = ['sphinx.ext.autodoc']
|
||||||
|
|
||||||
templates_path = ['_templates']
|
templates_path = ['_templates']
|
||||||
|
|
@ -11,7 +15,6 @@ master_doc = 'index'
|
||||||
project = u'vdirsyncer'
|
project = u'vdirsyncer'
|
||||||
copyright = u'2014, Markus Unterwaditzer & contributors'
|
copyright = u'2014, Markus Unterwaditzer & contributors'
|
||||||
|
|
||||||
import pkg_resources
|
|
||||||
try:
|
try:
|
||||||
# The full version, including alpha/beta/rc tags.
|
# The full version, including alpha/beta/rc tags.
|
||||||
release = pkg_resources.require('vdirsyncer')[0].version
|
release = pkg_resources.require('vdirsyncer')[0].version
|
||||||
|
|
@ -21,15 +24,12 @@ except pkg_resources.DistributionNotFound:
|
||||||
'this.')
|
'this.')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
del pkg_resources
|
|
||||||
|
|
||||||
version = '.'.join(release.split('.')[:2]) # The short X.Y version.
|
version = '.'.join(release.split('.')[:2]) # The short X.Y version.
|
||||||
|
|
||||||
exclude_patterns = ['_build']
|
exclude_patterns = ['_build']
|
||||||
|
|
||||||
pygments_style = 'sphinx'
|
pygments_style = 'sphinx'
|
||||||
|
|
||||||
import os
|
|
||||||
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
|
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
|
||||||
|
|
||||||
if not on_rtd:
|
if not on_rtd:
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,9 @@
|
||||||
:copyright: (c) 2014 Markus Unterwaditzer & contributors
|
:copyright: (c) 2014 Markus Unterwaditzer & contributors
|
||||||
:license: MIT, see LICENSE for more details.
|
:license: MIT, see LICENSE for more details.
|
||||||
'''
|
'''
|
||||||
|
import textwrap
|
||||||
|
|
||||||
|
import icalendar
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
@ -130,43 +133,86 @@ def test_multiline_uid():
|
||||||
|
|
||||||
|
|
||||||
def test_multiline_uid_complex():
|
def test_multiline_uid_complex():
|
||||||
a = u'''
|
a = textwrap.dedent(u'''
|
||||||
BEGIN:VCALENDAR
|
BEGIN:VCALENDAR
|
||||||
BEGIN:VTIMEZONE
|
BEGIN:VTIMEZONE
|
||||||
TZID:Europe/Rome
|
TZID:Europe/Rome
|
||||||
X-LIC-LOCATION:Europe/Rome
|
X-LIC-LOCATION:Europe/Rome
|
||||||
BEGIN:DAYLIGHT
|
BEGIN:DAYLIGHT
|
||||||
TZOFFSETFROM:+0100
|
TZOFFSETFROM:+0100
|
||||||
TZOFFSETTO:+0200
|
TZOFFSETTO:+0200
|
||||||
TZNAME:CEST
|
TZNAME:CEST
|
||||||
DTSTART:19700329T020000
|
DTSTART:19700329T020000
|
||||||
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3
|
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3
|
||||||
END:DAYLIGHT
|
END:DAYLIGHT
|
||||||
BEGIN:STANDARD
|
BEGIN:STANDARD
|
||||||
TZOFFSETFROM:+0200
|
TZOFFSETFROM:+0200
|
||||||
TZOFFSETTO:+0100
|
TZOFFSETTO:+0100
|
||||||
TZNAME:CET
|
TZNAME:CET
|
||||||
DTSTART:19701025T030000
|
DTSTART:19701025T030000
|
||||||
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
|
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
|
||||||
END:STANDARD
|
END:STANDARD
|
||||||
END:VTIMEZONE
|
END:VTIMEZONE
|
||||||
BEGIN:VEVENT
|
BEGIN:VEVENT
|
||||||
DTSTART:20140124T133000Z
|
DTSTART:20140124T133000Z
|
||||||
DTEND:20140124T143000Z
|
DTEND:20140124T143000Z
|
||||||
DTSTAMP:20140612T090652Z
|
DTSTAMP:20140612T090652Z
|
||||||
UID:040000008200E00074C5B7101A82E0080000000050AAABEEF50DCF0100000000000000
|
UID:040000008200E00074C5B7101A82E0080000000050AAABEEF50DCF
|
||||||
001000000062548482FA830A46B9EA62114AC9F0EF
|
001000000062548482FA830A46B9EA62114AC9F0EF
|
||||||
CREATED:20140110T102231Z
|
CREATED:20140110T102231Z
|
||||||
DESCRIPTION:Test.
|
DESCRIPTION:Test.
|
||||||
LAST-MODIFIED:20140123T095221Z
|
LAST-MODIFIED:20140123T095221Z
|
||||||
LOCATION:25.12.01.51
|
LOCATION:25.12.01.51
|
||||||
SEQUENCE:0
|
SEQUENCE:0
|
||||||
STATUS:CONFIRMED
|
STATUS:CONFIRMED
|
||||||
SUMMARY:Präsentation
|
SUMMARY:Präsentation
|
||||||
TRANSP:OPAQUE
|
TRANSP:OPAQUE
|
||||||
END:VEVENT
|
END:VEVENT
|
||||||
END:VCALENDAR
|
END:VCALENDAR
|
||||||
'''.strip()
|
''').strip()
|
||||||
assert vobject.Item(a).uid == (u'040000008200E00074C5B7101A82E008000000005'
|
assert vobject.Item(a).uid == (u'040000008200E00074C5B7101A82E008000000005'
|
||||||
u'0AAABEEF50DCF0100000000000000001000000062'
|
u'0AAABEEF50DCF001000000062548482FA830A46B9'
|
||||||
u'548482FA830A46B9EA62114AC9F0EF')
|
u'EA62114AC9F0EF')
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.xfail(icalendar.parser.NAME.findall('FOO.BAR') != ['FOO.BAR'],
|
||||||
|
reason=('version of icalendar doesn\'t support dots in '
|
||||||
|
'property names'))
|
||||||
|
def test_vcard_property_groups():
|
||||||
|
vcard = textwrap.dedent(u'''
|
||||||
|
BEGIN:VCARD
|
||||||
|
VERSION:3.0
|
||||||
|
MYLABEL123.ADR:;;This is the Address 08; Some City;;12345;Germany
|
||||||
|
MYLABEL123.X-ABLABEL:
|
||||||
|
FN:Some Name
|
||||||
|
N:Name;Some;;;Nickname
|
||||||
|
UID:67c15e43-34d2-4f55-a6c6-4adb7aa7e3b2
|
||||||
|
END:VCARD
|
||||||
|
''').strip()
|
||||||
|
|
||||||
|
book = u'BEGIN:VADDRESSBOOK\n' + vcard + u'\nEND:VADDRESSBOOK'
|
||||||
|
splitted = list(vobject.split_collection(book))
|
||||||
|
assert len(splitted) == 1
|
||||||
|
|
||||||
|
assert vobject.Item(vcard).hash == vobject.Item(splitted[0]).hash
|
||||||
|
assert 'is the Address' in vobject.Item(vcard).parsed['MYLABEL123.ADR']
|
||||||
|
|
||||||
|
|
||||||
|
def test_vcard_semicolons_in_values():
|
||||||
|
# If this test fails because proper vCard support was added to icalendar,
|
||||||
|
# we can remove some ugly postprocessing code in to_unicode_lines.
|
||||||
|
|
||||||
|
vcard = textwrap.dedent(u'''
|
||||||
|
BEGIN:VCARD
|
||||||
|
VERSION:3.0
|
||||||
|
ADR:;;Address 08;City;;12345;Germany
|
||||||
|
END:VCARD
|
||||||
|
''').strip()
|
||||||
|
|
||||||
|
# Assert that icalendar breaks vcard properties with semicolons in values
|
||||||
|
assert b'ADR:\\;\\;Address 08\\;City\\;\\;12345\\;Germany' in \
|
||||||
|
vobject.Item(vcard).parsed.to_ical().splitlines()
|
||||||
|
|
||||||
|
# Assert that vdirsyncer fixes these properties
|
||||||
|
assert u'ADR:;;Address 08;City;;12345;Germany' in \
|
||||||
|
list(vobject.to_unicode_lines(vobject.Item(vcard).parsed))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue