From a79d1ddb525fd2bd97b32a64850125ef0aafcc52 Mon Sep 17 00:00:00 2001 From: Markus Unterwaditzer Date: Sun, 13 Jul 2014 18:32:36 +0200 Subject: [PATCH 1/6] Indent multiline string. --- tests/utils/test_vobject.py | 80 +++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 39 deletions(-) diff --git a/tests/utils/test_vobject.py b/tests/utils/test_vobject.py index beff71c..8afc527 100644 --- a/tests/utils/test_vobject.py +++ b/tests/utils/test_vobject.py @@ -9,6 +9,8 @@ import pytest +import textwrap + import vdirsyncer.utils.vobject as vobject from .. import BARE_EVENT_TEMPLATE, EVENT_TEMPLATE, VCARD_TEMPLATE, \ @@ -130,43 +132,43 @@ def test_multiline_uid(): def test_multiline_uid_complex(): - a = u''' -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 -BEGIN:VEVENT -DTSTART:20140124T133000Z -DTEND:20140124T143000Z -DTSTAMP:20140612T090652Z -UID:040000008200E00074C5B7101A82E0080000000050AAABEEF50DCF0100000000000000 - 001000000062548482FA830A46B9EA62114AC9F0EF -CREATED:20140110T102231Z -DESCRIPTION:Test. -LAST-MODIFIED:20140123T095221Z -LOCATION:25.12.01.51 -SEQUENCE:0 -STATUS:CONFIRMED -SUMMARY:Präsentation -TRANSP:OPAQUE -END:VEVENT -END:VCALENDAR - '''.strip() + a = textwrap.dedent(u''' + 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 + BEGIN:VEVENT + DTSTART:20140124T133000Z + DTEND:20140124T143000Z + DTSTAMP:20140612T090652Z + UID:040000008200E00074C5B7101A82E0080000000050AAABEEF50DCF + 001000000062548482FA830A46B9EA62114AC9F0EF + CREATED:20140110T102231Z + DESCRIPTION:Test. + LAST-MODIFIED:20140123T095221Z + LOCATION:25.12.01.51 + SEQUENCE:0 + STATUS:CONFIRMED + SUMMARY:Präsentation + TRANSP:OPAQUE + END:VEVENT + END:VCALENDAR + ''').strip() assert vobject.Item(a).uid == (u'040000008200E00074C5B7101A82E008000000005' - u'0AAABEEF50DCF0100000000000000001000000062' - u'548482FA830A46B9EA62114AC9F0EF') + u'0AAABEEF50DCF001000000062548482FA830A46B9' + u'EA62114AC9F0EF') From c8f97b43ec003c3ec05864b6a59c4593ebc532f0 Mon Sep 17 00:00:00 2001 From: Markus Unterwaditzer Date: Sun, 13 Jul 2014 18:43:41 +0200 Subject: [PATCH 2/6] Add testcase for #89 --- tests/utils/test_vobject.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/tests/utils/test_vobject.py b/tests/utils/test_vobject.py index 8afc527..36b7360 100644 --- a/tests/utils/test_vobject.py +++ b/tests/utils/test_vobject.py @@ -6,11 +6,10 @@ :copyright: (c) 2014 Markus Unterwaditzer & contributors :license: MIT, see LICENSE for more details. ''' +import textwrap import pytest -import textwrap - import vdirsyncer.utils.vobject as vobject from .. import BARE_EVENT_TEMPLATE, EVENT_TEMPLATE, VCARD_TEMPLATE, \ @@ -172,3 +171,23 @@ def test_multiline_uid_complex(): assert vobject.Item(a).uid == (u'040000008200E00074C5B7101A82E008000000005' u'0AAABEEF50DCF001000000062548482FA830A46B9' u'EA62114AC9F0EF') + + +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'] From 97ad7eb27af189a27b8994384e6d003507b2cd79 Mon Sep 17 00:00:00 2001 From: Markus Unterwaditzer Date: Sun, 13 Jul 2014 19:11:59 +0200 Subject: [PATCH 3/6] Fix import order --- docs/conf.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 52a96e4..bf4f2d9 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,6 +1,10 @@ # -*- coding: utf-8 -*- +import os import sys + +import pkg_resources + extensions = ['sphinx.ext.autodoc'] templates_path = ['_templates'] @@ -11,7 +15,6 @@ master_doc = 'index' project = u'vdirsyncer' copyright = u'2014, Markus Unterwaditzer & contributors' -import pkg_resources try: # The full version, including alpha/beta/rc tags. release = pkg_resources.require('vdirsyncer')[0].version @@ -21,15 +24,12 @@ except pkg_resources.DistributionNotFound: 'this.') sys.exit(1) -del pkg_resources - version = '.'.join(release.split('.')[:2]) # The short X.Y version. exclude_patterns = ['_build'] pygments_style = 'sphinx' -import os on_rtd = os.environ.get('READTHEDOCS', None) == 'True' if not on_rtd: From dea468fcaaf1f85bb4311251acb12843bd436815 Mon Sep 17 00:00:00 2001 From: Markus Unterwaditzer Date: Sun, 13 Jul 2014 19:18:59 +0200 Subject: [PATCH 4/6] Xfail vcard group test --- tests/utils/test_vobject.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/utils/test_vobject.py b/tests/utils/test_vobject.py index 36b7360..a1f7d33 100644 --- a/tests/utils/test_vobject.py +++ b/tests/utils/test_vobject.py @@ -8,6 +8,7 @@ ''' import textwrap +import icalendar import pytest import vdirsyncer.utils.vobject as vobject @@ -173,6 +174,9 @@ def test_multiline_uid_complex(): 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 From e2fa26a71152eb4ca38f9a3bfe53d1f80b9c67bd Mon Sep 17 00:00:00 2001 From: Markus Unterwaditzer Date: Mon, 14 Jul 2014 15:15:50 +0200 Subject: [PATCH 5/6] Add another test related to vcards vs icalendar --- tests/utils/test_vobject.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/utils/test_vobject.py b/tests/utils/test_vobject.py index a1f7d33..61e9522 100644 --- a/tests/utils/test_vobject.py +++ b/tests/utils/test_vobject.py @@ -195,3 +195,23 @@ def test_vcard_property_groups(): 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 'ADR:\\;\\;Address 08\\;City\\;\\;12345\\;Germany' in \ + vobject.Item(vcard).parsed.to_ical() + + # Assert that vdirsyncer fixes these properties + assert 'ADR:;;Address 08;City;;12345;Germany' in \ + list(vobject.to_unicode_lines(vobject.Item(vcard).parsed)) From 0f44645e789035be2ba021d6a311a812cec0613f Mon Sep 17 00:00:00 2001 From: Markus Unterwaditzer Date: Mon, 14 Jul 2014 15:32:59 +0200 Subject: [PATCH 6/6] Formatting and string type fixes --- tests/utils/test_vobject.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/utils/test_vobject.py b/tests/utils/test_vobject.py index 61e9522..cc16478 100644 --- a/tests/utils/test_vobject.py +++ b/tests/utils/test_vobject.py @@ -9,6 +9,7 @@ import textwrap import icalendar + import pytest import vdirsyncer.utils.vobject as vobject @@ -209,9 +210,9 @@ def test_vcard_semicolons_in_values(): ''').strip() # Assert that icalendar breaks vcard properties with semicolons in values - assert 'ADR:\\;\\;Address 08\\;City\\;\\;12345\\;Germany' in \ - vobject.Item(vcard).parsed.to_ical() + assert b'ADR:\\;\\;Address 08\\;City\\;\\;12345\\;Germany' in \ + vobject.Item(vcard).parsed.to_ical().splitlines() # Assert that vdirsyncer fixes these properties - assert 'ADR:;;Address 08;City;;12345;Germany' in \ - list(vobject.to_unicode_lines(vobject.Item(vcard).parsed)) + assert u'ADR:;;Address 08;City;;12345;Germany' in \ + list(vobject.to_unicode_lines(vobject.Item(vcard).parsed))