From 96aae16c329977ec106b24d6cce116a7e20b664a Mon Sep 17 00:00:00 2001 From: Markus Unterwaditzer Date: Sun, 22 Jun 2014 00:21:29 +0200 Subject: [PATCH] Fix typo induced bug in split_collection --- tests/utils/test_vobject.py | 16 ++++++++++++++++ vdirsyncer/utils/vobject.py | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/utils/test_vobject.py b/tests/utils/test_vobject.py index 93ab063..600dc2a 100644 --- a/tests/utils/test_vobject.py +++ b/tests/utils/test_vobject.py @@ -7,6 +7,8 @@ :license: MIT, see LICENSE for more details. ''' +import pytest + import vdirsyncer.utils.vobject as vobject from .. import BARE_EVENT_TEMPLATE, EVENT_TEMPLATE, VCARD_TEMPLATE, \ @@ -52,6 +54,20 @@ def test_split_collection_multiple_wrappers(): assert [x.splitlines() for x in given] == \ [x.splitlines() for x in _simple_split] +def test_split_collection_different_wrappers(): + with pytest.raises(ValueError) as exc_info: + list(vobject.split_collection(u'BEGIN:VADDRESSBOOK\r\n' + u'BEGIN:FOO\r\n' + u'END:FOO\r\n' + u'END:VADDRESSBOOK\r\n' + u'BEGIN:VCALENDAR\r\n' + u'BEGIN:FOO\r\n' + u'END:FOO\r\n' + u'END:VCALENDAR\r\n')) + + assert 'different types of components at top-level' in \ + str(exc_info.value).lower() + def test_join_collection_simple(): given = vobject.join_collection(_simple_split) diff --git a/vdirsyncer/utils/vobject.py b/vdirsyncer/utils/vobject.py index 01452d7..151bcb5 100644 --- a/vdirsyncer/utils/vobject.py +++ b/vdirsyncer/utils/vobject.py @@ -143,7 +143,7 @@ def split_collection(text, inline=(u'VTIMEZONE',), else: start = end = u'' - if collection.name != collection.name: + if collection.name != collection_name: raise ValueError('Different types of components at top-level. ' 'Expected {}, got {}.' .format(collection_name, collection.name))