diff --git a/tests/__init__.py b/tests/__init__.py index 4896364..fc9fca9 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -18,7 +18,8 @@ vdirsyncer.log.set_level(vdirsyncer.log.logging.DEBUG) def normalize_item(item): if not isinstance(item, text_type): item = item.raw - return tuple(sorted(_normalize_item(item).splitlines())) + return tuple(sorted(_normalize_item( + item, use_icalendar=False).splitlines())) def assert_item_equals(a, b): diff --git a/tests/utils/test_vobject.py b/tests/utils/test_vobject.py index 506f0d5..227c65d 100644 --- a/tests/utils/test_vobject.py +++ b/tests/utils/test_vobject.py @@ -10,22 +10,21 @@ from vdirsyncer.utils.vobject import split_collection, join_collection, \ hash_item -from .. import normalize_item, SIMPLE_TEMPLATE, BARE_EVENT_TEMPLATE, \ +from .. import normalize_item, VCARD_TEMPLATE, BARE_EVENT_TEMPLATE, \ EVENT_TEMPLATE - _simple_joined = u'\r\n'.join(( u'BEGIN:VADDRESSBOOK', - SIMPLE_TEMPLATE.format(r=123), - SIMPLE_TEMPLATE.format(r=345), - SIMPLE_TEMPLATE.format(r=678), + VCARD_TEMPLATE.format(r=123), + VCARD_TEMPLATE.format(r=345), + VCARD_TEMPLATE.format(r=678), u'END:VADDRESSBOOK' )) _simple_split = [ - SIMPLE_TEMPLATE.format(r=123), - SIMPLE_TEMPLATE.format(r=345), - SIMPLE_TEMPLATE.format(r=678) + VCARD_TEMPLATE.format(r=123), + VCARD_TEMPLATE.format(r=345), + VCARD_TEMPLATE.format(r=678) ] @@ -36,10 +35,7 @@ def test_split_collection_simple(): def test_join_collection_simple(): - item_type = _simple_split[0].splitlines()[0][len(u'BEGIN:'):] - given = join_collection(_simple_split, wrappers={ - item_type: (u'VADDRESSBOOK', ()) - }) + given = join_collection(_simple_split) print(given) print(_simple_joined) assert normalize_item(given) == normalize_item(_simple_joined) diff --git a/vdirsyncer/utils/vobject.py b/vdirsyncer/utils/vobject.py index 19bc7b4..f0b1006 100644 --- a/vdirsyncer/utils/vobject.py +++ b/vdirsyncer/utils/vobject.py @@ -27,8 +27,10 @@ IGNORE_PROPS = frozenset(( )) -def normalize_item(text, ignore_props=IGNORE_PROPS): +def normalize_item(text, ignore_props=IGNORE_PROPS, use_icalendar=True): try: + if not use_icalendar: + raise Exception() lines = to_unicode_lines(icalendar.cal.Component.from_ical(text)) except Exception: lines = sorted(text.splitlines())