From 055ed62f16e0604e534ea438c67a1235371ddb11 Mon Sep 17 00:00:00 2001 From: Wolfgang Steitz Date: Thu, 2 Feb 2017 16:31:54 +0100 Subject: [PATCH] test: adding / removing calendar check --- test/test_caldav.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/test/test_caldav.py b/test/test_caldav.py index bea4e698..7b9964e1 100644 --- a/test/test_caldav.py +++ b/test/test_caldav.py @@ -32,7 +32,7 @@ def create_event(): uid = random_id() event = vcal.format(uid) return event, uid - + def event_exists(uid): c, cal = connect() @@ -48,19 +48,21 @@ def test_addremove_event(): event, uid = create_event() cal.add_event(event) assert event_exists(uid) - - # now delete the event again + + # now delete the event again event = cal.event(uid) event.delete() sleep(3) assert (not event_exists(uid)) - -#def test_addremove_calendar(): -# c, cal = connect() -# cal_id = random_id() -# #c.principal().make_calendar(name="test", cal_id=cal_id) -# cal = caldav.Calendar(c, name="TEST", parent=c.principal(), id="12").save() - - +def test_addremove_calendar(): + c, _ = connect() + cal_id = random_id() + cal = c.principal().make_calendar(name="test", cal_id=cal_id) + matching = [calendar for calendar in c.principal().calendars() if cal_id in str(calendar.url)] + assert len(matching) == 1 + + c.delete(cal.url) + matching = [calendar for calendar in c.principal().calendars() if cal_id in str(calendar.url)] + assert len(matching) == 0