def test_event_exdates_remove(self): """check if we can remove one more instance""" vevent = _get_vevent(event_exdatesl_dt) dtstart = icalendar_helpers.expand(vevent, berlin) assert len(dtstart) == 7 exdate1 = pytz.UTC.localize(dt.datetime(2014, 7, 11, 17, 0)) icalendar_helpers.delete_instance(vevent, exdate1) dtstart = icalendar_helpers.expand(vevent, berlin) assert len(dtstart) == 6 exdate2 = berlin.localize(dt.datetime(2014, 7, 9, 19, 0)) icalendar_helpers.delete_instance(vevent, exdate2) dtstart = icalendar_helpers.expand(vevent, berlin) assert len(dtstart) == 5
def test_until_d_notz(self): vevent = _get_vevent(event_until_d_notz) dtstart = icalendar_helpers.expand(vevent, berlin) starts = [start for start, _ in dtstart] assert len(starts) == 6 assert dtstart[0][0] == dt.date(2014, 1, 10) assert dtstart[-1][0] == dt.date(2014, 2, 14)
def test_expand_d(self): vevent = _get_vevent(event_d_norr) dtstart = icalendar_helpers.expand(vevent, berlin) assert dtstart == [ (dt.date(2013, 3, 1,), dt.date(2013, 3, 2,)), ]
def test_count(self): vevent = _get_vevent(vevent_count) dtstart = icalendar_helpers.expand(vevent, berlin) starts = [start for start, _ in dtstart] assert len(starts) == 18 assert dtstart[0][0] == dt.datetime(2014, 2, 3, 7, 0) assert dtstart[-1][0] == dt.datetime(2014, 2, 20, 7, 0)
def test_rrule_past(self): vevent = _get_vevent_file('event_r_past') assert vevent is not None dtstarts = icalendar_helpers.expand(vevent, berlin) assert len(dtstarts) == 73 assert dtstarts[0][0] == dt.date(1965, 4, 23) assert dtstarts[-1][0] == dt.date(2037, 4, 23)
def test_expand_dtb(self): vevent = _get_vevent(event_dtb_norr) dtstart = icalendar_helpers.expand(vevent, berlin) assert dtstart == self.dtstartend_berlin assert [start.utcoffset() for start, _ in dtstart] == self.offset_berlin assert [end.utcoffset() for _, end in dtstart] == self.offset_berlin
def test_until_notz(self): vevent = _get_vevent(vevent_until_notz) dtstart = icalendar_helpers.expand(vevent, berlin) starts = [start for start, _ in dtstart] assert len(starts) == 18 assert dtstart[0][0] == berlin.localize(dt.datetime(2014, 2, 3, 7, 0)) assert dtstart[-1][0] == berlin.localize(dt.datetime( 2014, 2, 20, 7, 0))
def test_event_exdatesl_dt(self): """recurring event, three dates exclude via two EXCLUDEs""" vevent = _get_vevent(event_exdatesl_dt) dtstart = icalendar_helpers.expand(vevent, berlin) assert len(dtstart) == 7 assert dtstart[0][0] == berlin.localize(dt.datetime(2014, 7, 2, 19, 0)) assert dtstart[-1][0] == berlin.localize( dt.datetime(2014, 7, 11, 19, 0))
def test_event_dt_rrule_invalid_until(self): """DTSTART and RRULE:UNTIL should be of the same type, but might not be""" vevent = _get_vevent(_get_text('event_dt_rrule_invalid_until')) dtstart = icalendar_helpers.expand(vevent, berlin) assert dtstart == [(dt.date(2007, 12, 1), dt.date(2007, 12, 2)), (dt.date(2008, 1, 1), dt.date(2008, 1, 2)), (dt.date(2008, 2, 1), dt.date(2008, 2, 2))]
def test_rdate_date(self): vevent = _get_vevent_file('event_d_rdate') dtstarts = icalendar_helpers.expand(vevent, berlin) assert len(dtstarts) == 4 assert dtstarts == [(dt.date(2015, 8, 12), dt.date(2015, 8, 13)), (dt.date(2015, 8, 13), dt.date(2015, 8, 14)), (dt.date(2015, 8, 14), dt.date(2015, 8, 15)), (dt.date(2015, 8, 15), dt.date(2015, 8, 16))]
def test_event_dt_rrule_invalid_until2(self): """same as above, but now dtstart is of type date and until is datetime """ vevent = _get_vevent(_get_text('event_dt_rrule_invalid_until2')) dtstart = icalendar_helpers.expand(vevent, berlin) assert len(dtstart) == 35 assert dtstart[0] == (berlin.localize(dt.datetime(2014, 4, 9, 9, 30)), berlin.localize(dt.datetime(2014, 4, 9, 10, 30))) assert dtstart[-1] == (berlin.localize(dt.datetime(2014, 12, 3, 9, 30)), berlin.localize(dt.datetime(2014, 12, 3, 10, 30)))
def test_expand_invalid_exdate(self): """testing if we can expand an event with EXDATEs that do not much its RRULE""" vevent = _get_vevent_file('event_invalid_exdate') dtstartl = icalendar_helpers.expand(vevent, berlin) # TODO test for logging message assert dtstartl == [ (new_york.localize(dt.datetime(2011, 11, 12, 15, 50)), new_york.localize(dt.datetime(2011, 11, 12, 17, 0))), (new_york.localize(dt.datetime(2011, 11, 19, 15, 50)), new_york.localize(dt.datetime(2011, 11, 19, 17, 0))), (new_york.localize(dt.datetime(2011, 12, 3, 15, 50)), new_york.localize(dt.datetime(2011, 12, 3, 17, 0))), ]
def test_expand_rrule_exdate_z(self): """event with not understood timezone for dtstart and zulu time form exdate """ vevent = _get_vevent_file('event_dtr_no_tz_exdatez') vevent = icalendar_helpers.sanitize(vevent, berlin, '', '') dtstart = icalendar_helpers.expand(vevent, berlin) assert len(dtstart) == 5 dtstarts = [start for start, end in dtstart] assert dtstarts == [ berlin.localize(dt.datetime(2012, 4, 3, 10, 0)), berlin.localize(dt.datetime(2012, 5, 3, 10, 0)), berlin.localize(dt.datetime(2012, 7, 3, 10, 0)), berlin.localize(dt.datetime(2012, 8, 3, 10, 0)), berlin.localize(dt.datetime(2012, 9, 3, 10, 0)), ]
def test_expand_rrule_notz_until_z(self): """event with not understood timezone for dtstart and zulu time form exdate """ vevent = _get_vevent_file('event_dtr_notz_untilz') vevent = icalendar_helpers.sanitize(vevent, new_york, '', '') dtstart = icalendar_helpers.expand(vevent, new_york) assert len(dtstart) == 7 dtstarts = [start for start, end in dtstart] assert dtstarts == [ new_york.localize(dt.datetime(2012, 7, 26, 13, 0)), new_york.localize(dt.datetime(2012, 8, 9, 13, 0)), new_york.localize(dt.datetime(2012, 8, 23, 13, 0)), new_york.localize(dt.datetime(2012, 9, 6, 13, 0)), new_york.localize(dt.datetime(2012, 9, 20, 13, 0)), new_york.localize(dt.datetime(2012, 10, 4, 13, 0)), new_york.localize(dt.datetime(2012, 10, 18, 13, 0)), ]
def test_recurrence_id_with_timezone(self): vevent = _get_vevent(recurrence_id_with_timezone) dtstart = icalendar_helpers.expand(vevent, berlin) assert len(dtstart) == 1 assert dtstart[0][0] == berlin.localize( dt.datetime(2013, 11, 13, 19, 0))
def test_expand_dtr_exdatez(self): """a recurring event with an EXDATE in Zulu time while DTSTART is localized""" vevent = _get_vevent_file('event_dtr_exdatez') dtstart = icalendar_helpers.expand(vevent, berlin) assert len(dtstart) == 3
def test_rrule_and_rdate(self): vevent = _get_vevent(rrule_and_rdate) dtstart = icalendar_helpers.expand(vevent, berlin) assert len(dtstart) == 7
def test_event_invalid_rrule(self): """test handling if an event with RRULE will never occur""" vevent = _get_vevent(_get_text('event_rrule_no_occurence')) dtstart = icalendar_helpers.expand(vevent, berlin) # TODO test for logging message assert dtstart is False
def test_event_dt_rrule_until_before_start(self): """test handling if an RRULE's UNTIL is before the event's DTSTART""" vevent = _get_vevent(_get_text('event_dt_rrule_until_before_start')) dtstart = icalendar_helpers.expand(vevent, berlin) # TODO test for logging message assert dtstart is False
def test_expand_dtzb(self): vevent = _get_vevent(event_dtzb) dtstart = icalendar_helpers.expand(vevent, berlin) assert dtstart == self.dstartend
def test_latest_bug(self): vevent = _get_vevent(latest_bug) dtstart = icalendar_helpers.expand(vevent, berlin) assert dtstart[0][0] == dt.date(2009, 10, 31) assert dtstart[-1][0] == dt.date(2037, 10, 31)