def testWholeDayEvent(self): props = Event(summary="Event", uid="1234") props.add('dtstart', dt.date(2017, 6, 5)) props.add('dtend', dt.date(2017, 6, 6)) props.add('dtstamp', vDt(timezone.make_aware(dt.datetime(2016, 6, 7, 8)))) vev = self.factory.makeFromProps(props, None) self.assertIs(type(vev), SimpleVEvent)
def testMultipleRRules(self): props = Event() addProps( props, summary="Event", uid="1234", dtstart=dt.datetime(2016, 4, 5, 9), dtend=dt.datetime(2016, 4, 5, 13), dtstamp=dt.datetime(2016, 4, 5, 13), rrule=vRecur.from_ical("FREQ=WEEKLY;WKST=SU;BYDAY=MO,TU,WE,TH,FR")) props.add('rrule', vRecur.from_ical("FREQ=MONTHLY;WKST=SU;BYDAY=-1SA,-1SU")) with self.assertRaises(CalendarTypeError) as expected: self.factory.makeFromProps(props, None) self.assertEqual(str(expected.exception), "Multiple RRULEs")
def testDiffTZsDtstartRecurrenceId(self): tz1 = pytz.timezone("Pacific/Auckland") tz2 = pytz.timezone("Australia/Sydney") props = Event() addProps(props, summary="Event", uid="1234", dtstart=timezone.make_aware(dt.datetime(2016, 6, 1, 7), tz1), dtend=timezone.make_aware(dt.datetime(2016, 6, 1, 10), tz1), dtstamp=timezone.make_aware(dt.datetime(2016, 6, 1, 8), tz2)) props.add('RECURRENCE-ID', timezone.make_aware(dt.datetime(2016, 6, 1, 8), tz2)) with self.assertRaises(CalendarTypeError) as expected: self.factory.makeFromProps(props, None) self.assertEqual(str(expected.exception), "DTSTART.timezone != RECURRENCE-ID.timezone")
def testMissingUid(self): props = Event() addProps(props, summary="Event", dtstart=dt.datetime(2016, 4, 5, 9), dtend=dt.datetime(2016, 4, 5, 13)) with self.assertRaises(CalendarTypeError) as expected: self.factory.makeFromProps(props, None) self.assertEqual(str(expected.exception), "Missing UID")
def testNoDuration(self): props = Event() addProps(props, summary="Event", uid="1234", dtstart=dt.date(2016, 6, 1), dtstamp=timezone.make_aware(dt.datetime(2016, 6, 1, 8))) vev = self.factory.makeFromProps(props, None) self.assertIs(type(vev), SimpleVEvent) self.assertEqual(vev['DTSTART'], dt.date(2016, 6, 1)) self.assertEqual(vev['DTEND'], dt.date(2016, 6, 2))
def testDtstartDtendTypes(self): props = Event() addProps(props, summary="Event", uid="1234", dtstart=dt.datetime(2016, 4, 5, 9), dtend=dt.date(2016, 4, 5), dtstamp=dt.datetime(2016, 4, 5, 13)) with self.assertRaises(CalendarTypeError) as expected: self.factory.makeFromProps(props, None) self.assertEqual(str(expected.exception), "DTSTART and DTEND types do not match")
def testDtendAndDuration(self): props = Event() addProps(props, summary="Event", uid="1234", dtstart=dt.datetime(2016, 4, 5, 9), dtend=dt.datetime(2016, 4, 5, 13), dtstamp=dt.datetime(2016, 4, 5, 13), duration=dt.timedelta(2)) with self.assertRaises(CalendarTypeError) as expected: self.factory.makeFromProps(props, None) self.assertEqual(str(expected.exception), "Both DURATION and DTEND set")