Fix typo induced bug in split_collection

This commit is contained in:
Markus Unterwaditzer 2014-06-22 00:21:29 +02:00
parent 2cc375aee6
commit 96aae16c32
2 changed files with 17 additions and 1 deletions

View file

@ -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)

View file

@ -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))