def test_join_collection_vevents(benchmark): actual = benchmark(lambda: vobject.join_collection([ dedent(""" BEGIN:VCALENDAR BEGIN:VTIMEZONE VALUE:The Timezone END:VTIMEZONE BEGIN:VEVENT VALUE:Event {} END:VEVENT END:VCALENDAR """).format(i) for i in range(3) ])) expected = dedent(""" BEGIN:VCALENDAR BEGIN:VTIMEZONE VALUE:The Timezone END:VTIMEZONE BEGIN:VEVENT VALUE:Event 0 END:VEVENT BEGIN:VEVENT VALUE:Event 1 END:VEVENT BEGIN:VEVENT VALUE:Event 2 END:VEVENT END:VCALENDAR """).lstrip() assert actual.splitlines() == expected.splitlines()
def test_join_collection_vevents(): actual = vobject.join_collection([ dedent(""" BEGIN:VCALENDAR BEGIN:VTIMEZONE VALUE:The Timezone END:VTIMEZONE BEGIN:VEVENT VALUE:Event {} END:VEVENT END:VCALENDAR """).format(i) for i in range(3) ]) expected = dedent(""" BEGIN:VCALENDAR BEGIN:VTIMEZONE VALUE:The Timezone END:VTIMEZONE BEGIN:VEVENT VALUE:Event 0 END:VEVENT BEGIN:VEVENT VALUE:Event 1 END:VEVENT BEGIN:VEVENT VALUE:Event 2 END:VEVENT END:VCALENDAR """).lstrip() assert actual.splitlines() == expected.splitlines()
def test_split_contacts(): bare = "\r\n".join([VCARD_TEMPLATE.format(r=x, uid=x) for x in range(4)]) with_wrapper = "BEGIN:VADDRESSBOOK\r\n" + bare + "\nEND:VADDRESSBOOK\r\n" for _ in (bare, with_wrapper): split = list(vobject.split_collection(bare)) assert len(split) == 4 assert vobject.join_collection(split).splitlines() == with_wrapper.splitlines()
def test_split_contacts(): bare = '\r\n'.join([VCARD_TEMPLATE.format(r=x, uid=x) for x in range(4)]) with_wrapper = 'BEGIN:VADDRESSBOOK\r\n' + bare + '\nEND:VADDRESSBOOK\r\n' for x in (bare, with_wrapper): split = list(vobject.split_collection(bare)) assert len(split) == 4 assert vobject.join_collection(split).splitlines() == \ with_wrapper.splitlines()
def test_join_collection_vevents(benchmark): actual = benchmark(lambda: vobject.join_collection([ dedent(""" BEGIN:VCALENDAR VERSION:2.0 PRODID:HUEHUE BEGIN:VTIMEZONE VALUE:The Timezone END:VTIMEZONE BEGIN:VEVENT VALUE:Event {} END:VEVENT END:VCALENDAR """).format(i) for i in range(3) ])) expected = dedent(""" BEGIN:VCALENDAR VERSION:2.0 PRODID:HUEHUE BEGIN:VTIMEZONE VALUE:The Timezone END:VTIMEZONE BEGIN:VEVENT VALUE:Event 0 END:VEVENT BEGIN:VEVENT VALUE:Event 1 END:VEVENT BEGIN:VEVENT VALUE:Event 2 END:VEVENT END:VCALENDAR """).lstrip() assert actual.splitlines() == expected.splitlines()
def test_join_collection_simple(benchmark): given = benchmark(lambda: vobject.join_collection(_simple_split)) assert normalize_item(given) == normalize_item(_simple_joined) assert given.splitlines() == _simple_joined.splitlines()
def test_join_collection_simple(): given = vobject.join_collection(_simple_split) assert normalize_item(given) == normalize_item(_simple_joined) if vobject.ICALENDAR_ORIGINAL_ORDER_SUPPORT: assert given.splitlines() == _simple_joined.splitlines()