def testCustomMonthly(self): self.Import(self.view, 'CustomRecurMonthly.ics') event = pim.EventStamp(sharing.findUID( self.view, 'AFAF34CC-827E-43EE-A7BB-004F7685E09E')) #### monthly, first wed params = self.makeParams(event) weekly = CustomRecurrenceDialog.extractIsWeekly(params) self.failUnlessEqual(False, weekly) monthly = CustomRecurrenceDialog.extractIsMonthly(params) self.failUnlessEqual(True, monthly) tuples = CustomRecurrenceDialog.extractGuiByWeekday(params) self.failUnlessEqual([(3, 1)], tuples) self.failUnlessEqual(1, CustomRecurrenceDialog.extractInterval(params)) #### monthly, last thu event = pim.EventStamp(sharing.findUID( self.view, '1F9963CE-56D6-4C76-8C8A-444A9DF6A4C5')) params = self.makeParams(event) weekly = CustomRecurrenceDialog.extractIsWeekly(params) self.failUnlessEqual(False, weekly) monthly = CustomRecurrenceDialog.extractIsMonthly(params) self.failUnlessEqual(True, monthly) tuples = CustomRecurrenceDialog.extractGuiByWeekday(params) self.failUnlessEqual([(4, -1)], tuples) self.failUnlessEqual(1, CustomRecurrenceDialog.extractInterval(params))
def testCustomWeekly(self): self.Import(self.view, 'CustomRecurWeekly.ics') event = pim.EventStamp( sharing.findUID(self.view, '431391D1-5CEB-4326-9AE2-7D87B8494E63')) #### this one is fri/sat every other week params = self.makeParams(event) weekly = CustomRecurrenceDialog.extractIsWeekly(params) self.failUnlessEqual(True, weekly) days = CustomRecurrenceDialog.extractGuiWeekdays(params) self.failUnlessEqual([5, 6], days) # assumes i18n first day is Sun self.failUnlessEqual(2, CustomRecurrenceDialog.extractInterval(params)) #### every monday, weekly event = pim.EventStamp( sharing.findUID(self.view, 'A2A6E03B-18D6-4364-9455-6155FD2B7F1A')) params = self.makeParams(event) weekly = CustomRecurrenceDialog.extractIsWeekly(params) self.failUnlessEqual(True, weekly) days = CustomRecurrenceDialog.extractGuiWeekdays(params) guiEventDay = CustomRecurrenceDialog._rr_weekday_to_gui( event.startTime.weekday()) self.failUnless([1] == days or guiEventDay == 1) self.failUnlessEqual(1, CustomRecurrenceDialog.extractInterval(params)) #### every sun/tue/thu event = pim.EventStamp( sharing.findUID(self.view, '00516393-29AF-4DF6-A786-51C7DDBDCCF8')) params = self.makeParams(event) weekly = CustomRecurrenceDialog.extractIsWeekly(params) self.failUnlessEqual(True, weekly) days = CustomRecurrenceDialog.extractGuiWeekdays(params) self.failUnlessEqual([0, 2, 4], days) self.failUnlessEqual(1, CustomRecurrenceDialog.extractInterval(params))
def testCustomMonthly(self): self.Import(self.view, 'CustomRecurMonthly.ics') event = pim.EventStamp( sharing.findUID(self.view, 'AFAF34CC-827E-43EE-A7BB-004F7685E09E')) #### monthly, first wed params = self.makeParams(event) weekly = CustomRecurrenceDialog.extractIsWeekly(params) self.failUnlessEqual(False, weekly) monthly = CustomRecurrenceDialog.extractIsMonthly(params) self.failUnlessEqual(True, monthly) tuples = CustomRecurrenceDialog.extractGuiByWeekday(params) self.failUnlessEqual([(3, 1)], tuples) self.failUnlessEqual(1, CustomRecurrenceDialog.extractInterval(params)) #### monthly, last thu event = pim.EventStamp( sharing.findUID(self.view, '1F9963CE-56D6-4C76-8C8A-444A9DF6A4C5')) params = self.makeParams(event) weekly = CustomRecurrenceDialog.extractIsWeekly(params) self.failUnlessEqual(False, weekly) monthly = CustomRecurrenceDialog.extractIsMonthly(params) self.failUnlessEqual(True, monthly) tuples = CustomRecurrenceDialog.extractGuiByWeekday(params) self.failUnlessEqual([(4, -1)], tuples) self.failUnlessEqual(1, CustomRecurrenceDialog.extractInterval(params))
def doRoundTripRecurrenceCountTest(self, tzName): from osaf.pim.calendar.TimeZone import TimeZoneInfo tzinfo = TimeZoneInfo.get(self.view) tzPrefs = schema.ns('osaf.pim', self.view).TimezonePrefs saveTz = tzinfo.default saveShowUI = tzPrefs.showUI tzinfo.default = self.view.tzinfo.getInstance(tzName) try: self.Import(self.view, u'Recurrence.ics') event = pim.EventStamp( sharing.findUID(self.view, '5B30A574-02A3-11DA-AA66-000A95DA3228')) third = event.getFirstOccurrence().getNextOccurrence( ).getNextOccurrence() self.assertEqual(third.summary, u'\u00FCChanged title') self.assertEqual( third.recurrenceID, datetime.datetime(2005, 8, 10, tzinfo=self.view.tzinfo.floating)) # while were at it, test bug 3509, all day event duration is off by one self.assertEqual(event.duration, datetime.timedelta(0)) # make sure we imported the floating EXDATE event = pim.EventStamp( sharing.findUID(self.view, '07f3d6f0-4c04-11da-b671-0013ce40e90f')) self.assertEqual( event.rruleset.exdates[0], datetime.datetime(2005, 12, 6, 12, 30, tzinfo=self.view.tzinfo.floating)) # test count export, no timezones vcalendar = getVObjectData(self.view, [event.itsItem]) self.assertEqual(vcalendar.vevent.rruleset._rrule[0]._count, 10) # turn on timezones, putting event in Pacific time pacific = self.view.tzinfo.getInstance("America/Los_Angeles") TimeZoneInfo.get(self.view).default = pacific schema.ns('osaf.pim', self.view).TimezonePrefs.showUI = True self.assertEqual(event.startTime.tzinfo, pacific) # test count export, with timezones turned on vcalendar = getVObjectData(self.view, [event.itsItem]) self.assertEqual(vcalendar.vevent.rruleset._rrule[0]._count, 10) finally: # Restore global settings tzPrefs.showUI = saveShowUI tzinfo.default = saveTz
def testImport(self): path = self.getTestResourcePath('icaluid.ics') sharing.importFile(self.view, path) # This item had a UUID-friendly icalUID, but its UUID shouldn't be used uid1 = 'BED962E5-6042-11D9-BE74-000A95BB2738' item1 = sharing.findUID(self.view, uid1) self.assert_(item1) self.failIfEqual(item1.itsUUID.str16(), uid1) # This item did not have a UUID-friendly icalUID, so we hashed it uid2 = 'Depeche-Mode' item2 = sharing.findUID(self.view, uid1) self.assert_(item2)
def doRoundTripRecurrenceCountTest(self, tzName): from osaf.pim.calendar.TimeZone import TimeZoneInfo tzinfo = TimeZoneInfo.get(self.view) tzPrefs = schema.ns('osaf.pim', self.view).TimezonePrefs saveTz = tzinfo.default saveShowUI = tzPrefs.showUI tzinfo.default = self.view.tzinfo.getInstance(tzName) try: self.Import(self.view, u'Recurrence.ics') event = pim.EventStamp(sharing.findUID(self.view, '5B30A574-02A3-11DA-AA66-000A95DA3228')) third = event.getFirstOccurrence().getNextOccurrence().getNextOccurrence() self.assertEqual(third.summary, u'\u00FCChanged title') self.assertEqual( third.recurrenceID, datetime.datetime(2005, 8, 10, tzinfo=self.view.tzinfo.floating) ) # while were at it, test bug 3509, all day event duration is off by one self.assertEqual(event.duration, datetime.timedelta(0)) # make sure we imported the floating EXDATE event = pim.EventStamp(sharing.findUID(self.view, '07f3d6f0-4c04-11da-b671-0013ce40e90f')) self.assertEqual( event.rruleset.exdates[0], datetime.datetime(2005, 12, 6, 12, 30, tzinfo=self.view.tzinfo.floating) ) # test count export, no timezones vcalendar = getVObjectData(self.view, [event.itsItem]) self.assertEqual(vcalendar.vevent.rruleset._rrule[0]._count, 10) # turn on timezones, putting event in Pacific time pacific = self.view.tzinfo.getInstance("America/Los_Angeles") TimeZoneInfo.get(self.view).default = pacific schema.ns('osaf.pim', self.view).TimezonePrefs.showUI = True self.assertEqual(event.startTime.tzinfo, pacific) # test count export, with timezones turned on vcalendar = getVObjectData(self.view, [event.itsItem]) self.assertEqual(vcalendar.vevent.rruleset._rrule[0]._count, 10) finally: # Restore global settings tzPrefs.showUI = saveShowUI tzinfo.default = saveTz
def testImportUnusualTzid(self): self.Import(self.view, u'UnusualTzid.ics') event = pim.EventStamp(sharing.findUID( self.view, '42583280-8164-11da-c77c-0011246e17f0')) mountain_time = self.view.tzinfo.getInstance('America/Denver') self.assertEqual(event.startTime.tzinfo, mountain_time)
def testFindEventUID(self): uid = u'123' self.failUnless(sharing.findUID(self.view, uid) is None) event = Calendar.CalendarEvent(itsView=self.view, displayName=u"event test", startTime=datetime.datetime( 2010, 1, 1, 10), duration=datetime.timedelta(hours=2)) self.failUnless(sharing.findUID(self.view, uid) is None) item = event.itsItem setattr(item, Note.icalUID.name, uid) self.failUnless(sharing.findUID(self.view, uid) is item)
def testImportReminders(self): # @@@ [grant] Check for that reminders end up expired or not, as # appropriate. self.Import(self.view, u'RecurrenceWithAlarm.ics') future = pim.EventStamp(sharing.findUID(self.view, 'RecurringAlarmFuture')) reminder = future.itsItem.getUserReminder() # this will start failing in 2015... self.assertEqual(reminder.delta, datetime.timedelta(minutes=-5)) second = future.getFirstOccurrence().getNextOccurrence() self.failUnless(second.itsItem.reminders is future.itsItem.reminders) past = pim.EventStamp(sharing.findUID(self.view, 'RecurringAlarmPast')) reminder = past.itsItem.getUserReminder() self.assertEqual(reminder.delta, datetime.timedelta(hours=-1)) second = past.getFirstOccurrence().getNextOccurrence() self.failUnless(second.itsItem.reminders is past.itsItem.reminders)
def testImportReminders(self): # @@@ [grant] Check for that reminders end up expired or not, as # appropriate. self.Import(self.view, u'RecurrenceWithAlarm.ics') future = pim.EventStamp( sharing.findUID(self.view, 'RecurringAlarmFuture')) reminder = future.itsItem.getUserReminder() # this will start failing in 2015... self.assertEqual(reminder.delta, datetime.timedelta(minutes=-5)) second = future.getFirstOccurrence().getNextOccurrence() self.failUnless(second.itsItem.reminders is future.itsItem.reminders) past = pim.EventStamp(sharing.findUID(self.view, 'RecurringAlarmPast')) reminder = past.itsItem.getUserReminder() self.assertEqual(reminder.delta, datetime.timedelta(hours=-1)) second = past.getFirstOccurrence().getNextOccurrence() self.failUnless(second.itsItem.reminders is past.itsItem.reminders)
def testImportAbsoluteReminder(self): self.Import(self.view, u'AbsoluteReminder.ics') eventItem = sharing.findUID(self.view, 'I-have-an-absolute-reminder') reminder = eventItem.getUserReminder() self.failUnless(reminder is not None, "No reminder was set") self.failUnlessEqual(reminder.absoluteTime, datetime.datetime(2006, 9, 25, 8, tzinfo=self.view.tzinfo.getInstance('America/Los_Angeles')))
def testNoMaster(self): """ Treat a modification without a master as a normal event, because Google exports events like this, bug 10821. """ self.Import(self.view, u'NoMaster.ics') event = pim.EventStamp(sharing.findUID(self.view, 'no_master')) rruleset = getattr(event, 'rruleset', None) self.assertEqual(rruleset, None)
def testFindEventUID(self): uid = u'123' self.failUnless(sharing.findUID(self.view, uid) is None) event = Calendar.CalendarEvent( itsView = self.view, displayName = u"event test", startTime = datetime.datetime(2010, 1, 1, 10), duration = datetime.timedelta(hours=2)) self.failUnless(sharing.findUID(self.view, uid) is None) item = event.itsItem setattr(item, Note.icalUID.name, uid) self.failUnless(sharing.findUID(self.view, uid) is item)
def testMidnightToMidnight(self): """ When importing iCalendar data, treat floating midnight-to-midnight events as all-day, bug 9579. """ self.Import(self.view, u'MidnightToMidnight.ics') event = pim.EventStamp(sharing.findUID(self.view, 'midnight')) endTime = datetime.datetime(2007, 6, 20) self.assert_(event.effectiveEndTime.replace(tzinfo=None) == endTime) self.assert_(event.allDay == True)
def testMidnightToMidnight(self): """ When importing iCalendar data, treat floating midnight-to-midnight events as all-day, bug 9579. """ self.Import(self.view, u'MidnightToMidnight.ics') event = pim.EventStamp(sharing.findUID(self.view, 'midnight')) endTime = datetime.datetime(2007,6,20) self.assert_(event.effectiveEndTime.replace(tzinfo=None) == endTime) self.assert_(event.allDay == True)
def testDateImportAsAllDay(self): self.Import(self.view, u'AllDay.ics') event = pim.EventStamp(sharing.findUID(self.view, 'testAllDay')) self.failUnless(pim.has_stamp(event, pim.EventStamp)) self.assert_(event.startTime == datetime.datetime(2005,1,1, tzinfo=self.view.tzinfo.floating), "startTime not set properly for all day event, startTime is %s" % event.startTime) self.assert_(event.allDay == True, "allDay not set properly for all day event, allDay is %s" % event.allDay)
def testDelete(self): task = pim.Task(itsView=self.view) # Set the task's UID .... task.itsItem.icalUID = u'yay' # Delete it ... task.itsItem.delete(recursive=True) # ... and fail if it can still be found self.failIf(sharing.findUID(self.view, u'yay') is not None)
def testSummaryAndDateTimeImported(self): self.Import(self.view, u'Chandler.ics') event = pim.EventStamp(sharing.findUID( self.view, 'BED962E5-6042-11D9-BE74-000A95BB2738')) self.assertEqual(event.summary, u'3 ho\u00FCr event', u"SUMMARY of first VEVENT not imported correctly, displayName is %s" % event.summary) evtime = datetime.datetime(2005,1,1, hour = 23, tzinfo = self.utc) self.assert_(event.startTime == evtime, "startTime not set properly, startTime is %s" % event.startTime)
def testDisplayAlarm(self): """Check we initialize a Reminder correctly from a VALARM element""" self.Import(self.view, 'DisplayAlarm.ics') eventItem = sharing.findUID(self.view, 'eventfrombug10958') reminder = eventItem.getUserReminder() self.failUnless(reminder is not None, "Reminder not set up from VALARM") self.failUnlessEqual(reminder.duration, datetime.timedelta(days=1)) self.failUnlessEqual(reminder.repeat, 4) self.failUnlessEqual(reminder.description, u'Wake up!') self.failUnlessEqual(reminder.delta, datetime.timedelta(days=-5))
def testSummaryAndDateTimeImported(self): self.Import(self.view, u'Chandler.ics') event = pim.EventStamp( sharing.findUID(self.view, 'BED962E5-6042-11D9-BE74-000A95BB2738')) self.assertEqual( event.summary, u'3 ho\u00FCr event', u"SUMMARY of first VEVENT not imported correctly, displayName is %s" % event.summary) evtime = datetime.datetime(2005, 1, 1, hour=23, tzinfo=self.utc) self.assert_( event.startTime == evtime, "startTime not set properly, startTime is %s" % event.startTime)
def testDateValuedExDate(self): self.Import(self.view, u'AllDayRecurrence.ics') event = pim.EventStamp(sharing.findUID(self.view, 'testAllDay')) self.assertEqual(len(event.rruleset.exdates), 2) self.assertEqual( event.rruleset.exdates[0], datetime.datetime(2007, 10, 15, 0, 0, tzinfo=self.view.tzinfo.floating) ) self.assertEqual( event.rruleset.exdates[1], datetime.datetime(2007, 10, 29, 0, 0, tzinfo=self.view.tzinfo.floating) )
def testImportAbsoluteReminder(self): self.Import(self.view, u'AbsoluteReminder.ics') eventItem = sharing.findUID(self.view, 'I-have-an-absolute-reminder') reminder = eventItem.getUserReminder() self.failUnless(reminder is not None, "No reminder was set") self.failUnlessEqual( reminder.absoluteTime, datetime.datetime( 2006, 9, 25, 8, tzinfo=self.view.tzinfo.getInstance('America/Los_Angeles')))
def testUpdate(self): uid = u'on-a-limo-to-milano-solo-gigolos-dont-nod' task = pim.Task(itsView=self.view) task.itsItem.icalUID = uid event = Calendar.CalendarEvent(itsView=self.view, startTime=datetime.datetime(2000, 1, 1)) event.itsItem.icalUID = uid del task.itsItem.icalUID # Necessary? self.failUnless(event.itsItem is sharing.findUID(self.view, uid))
def testDateImportAsAllDay(self): self.Import(self.view, u'AllDay.ics') event = pim.EventStamp(sharing.findUID(self.view, 'testAllDay')) self.failUnless(pim.has_stamp(event, pim.EventStamp)) self.assert_( event.startTime == datetime.datetime( 2005, 1, 1, tzinfo=self.view.tzinfo.floating), "startTime not set properly for all day event, startTime is %s" % event.startTime) self.assert_( event.allDay == True, "allDay not set properly for all day event, allDay is %s" % event.allDay)
def testCustomWeekly(self): self.Import(self.view, 'CustomRecurWeekly.ics') event = pim.EventStamp(sharing.findUID( self.view, '431391D1-5CEB-4326-9AE2-7D87B8494E63')) #### this one is fri/sat every other week params = self.makeParams(event) weekly = CustomRecurrenceDialog.extractIsWeekly(params) self.failUnlessEqual(True, weekly) days = CustomRecurrenceDialog.extractGuiWeekdays(params) self.failUnlessEqual([5, 6], days) # assumes i18n first day is Sun self.failUnlessEqual(2, CustomRecurrenceDialog.extractInterval(params)) #### every monday, weekly event = pim.EventStamp(sharing.findUID( self.view, 'A2A6E03B-18D6-4364-9455-6155FD2B7F1A')) params = self.makeParams(event) weekly = CustomRecurrenceDialog.extractIsWeekly(params) self.failUnlessEqual(True, weekly) days = CustomRecurrenceDialog.extractGuiWeekdays(params) guiEventDay = CustomRecurrenceDialog._rr_weekday_to_gui( event.startTime.weekday()) self.failUnless([1] == days or guiEventDay == 1) self.failUnlessEqual(1, CustomRecurrenceDialog.extractInterval(params)) #### every sun/tue/thu event = pim.EventStamp(sharing.findUID( self.view, '00516393-29AF-4DF6-A786-51C7DDBDCCF8')) params = self.makeParams(event) weekly = CustomRecurrenceDialog.extractIsWeekly(params) self.failUnlessEqual(True, weekly) days = CustomRecurrenceDialog.extractGuiWeekdays(params) self.failUnlessEqual([0, 2, 4], days) self.failUnlessEqual(1, CustomRecurrenceDialog.extractInterval(params))
def failUnlessHolidayMatches(self, uid, year, month, day): holidays = self.getCollection(u"U.S. Holidays") event = pim.EventStamp(sharing.findUID(self.view, uid)) self.failUnless(event.itsItem in holidays) targetDate = date(year, month, day) d = datetime.combine(targetDate, time(0, tzinfo=self.view.tzinfo.default)) matches = event.getOccurrencesBetween(d - timedelta(days=1), d + timedelta(days=1)) self.failUnlessEqual(len(matches), 1) matchEvent = matches[0] self.failUnlessEqual(matchEvent.startTime.date(), targetDate) self.failUnless(matchEvent.allDay)
def testImportRecurrenceWithTimezone(self): self.Import(self.view, u'RecurrenceWithTimezone.ics') event = pim.EventStamp(sharing.findUID(self.view, 'FF14A660-02A3-11DA-AA66-000A95DA3228')) mods = [evt for evt in event.modifications if not pim.EventStamp(evt).isTriageOnlyModification()] # The old ICalendar import code would handle THISANDFUTURE changes by # creating a new series, so there would be no modifications to the # original. The current code just ignores THISANDFUTURE changes, # so there should still be no modifications self.assertEqual(len(mods), 0) # Bug 6994, EXDATEs need to have ICU timezones, or they won't commit # (unless we're suffering from Bug 7023, in which case tzinfos are # changed silently, often to GMT, without raising an exception) self.assertEqual(event.rruleset.exdates[0].tzinfo, self.view.tzinfo.getInstance('US/Central'))
def testImportRecurrenceWithTimezone(self): self.Import(self.view, u'RecurrenceWithTimezone.ics') event = pim.EventStamp( sharing.findUID(self.view, 'FF14A660-02A3-11DA-AA66-000A95DA3228')) mods = [ evt for evt in event.modifications if not pim.EventStamp(evt).isTriageOnlyModification() ] # The old ICalendar import code would handle THISANDFUTURE changes by # creating a new series, so there would be no modifications to the # original. The current code just ignores THISANDFUTURE changes, # so there should still be no modifications self.assertEqual(len(mods), 0) # Bug 6994, EXDATEs need to have ICU timezones, or they won't commit # (unless we're suffering from Bug 7023, in which case tzinfos are # changed silently, often to GMT, without raising an exception) self.assertEqual(event.rruleset.exdates[0].tzinfo, self.view.tzinfo.getInstance('US/Central'))
def testWeekdayEvent(self): self.Import(self.view, 'WeekdayEvent.ics') event = pim.EventStamp( sharing.findUID(self.view, '5fc9f9a2-0655-11dd-8f5a-0016cbca6aed')) rruleset = event.rruleset self.failUnless(rruleset is not None) self.failUnlessEqual(len(list(rruleset.rrules)), 1) rrule = rruleset.rrules.first() self.failUnlessEqual(rrule.freq, 'weekly') self.failUnlessEqual(rrule.interval, 1) self.failUnlessEqual([(ws.weekday, ws.selector) for ws in rrule.byweekday], [('monday', 0), ('tuesday', 0), ('wednesday', 0), ('thursday', 0), ('friday', 0)]) self.failUnless(rrule.isWeekdayRule())
def testDateValuedExDate(self): self.Import(self.view, u'AllDayRecurrence.ics') event = pim.EventStamp(sharing.findUID(self.view, 'testAllDay')) self.assertEqual(len(event.rruleset.exdates), 2) self.assertEqual( event.rruleset.exdates[0], datetime.datetime(2007, 10, 15, 0, 0, tzinfo=self.view.tzinfo.floating)) self.assertEqual( event.rruleset.exdates[1], datetime.datetime(2007, 10, 29, 0, 0, tzinfo=self.view.tzinfo.floating))
def testWeekdayEvent(self): self.Import(self.view, 'WeekdayEvent.ics') event = pim.EventStamp(sharing.findUID( self.view, '5fc9f9a2-0655-11dd-8f5a-0016cbca6aed')) rruleset = event.rruleset self.failUnless(rruleset is not None) self.failUnlessEqual(len(list(rruleset.rrules)), 1) rrule = rruleset.rrules.first() self.failUnlessEqual(rrule.freq, 'weekly') self.failUnlessEqual(rrule.interval, 1) self.failUnlessEqual( [(ws.weekday, ws.selector) for ws in rrule.byweekday], [ ('monday', 0), ('tuesday', 0), ('wednesday', 0), ('thursday', 0), ('friday', 0) ] ) self.failUnless(rrule.isWeekdayRule())
def _testImportOracleModification(self): # XXX this test is broken # switch to no-timezones mode schema.ns('osaf.pim', self.view).TimezonePrefs.showUI = False # Oracle modifies recurring events by first, if the time changed, adding # an EXDATE for the old time plus an RDATE for the new time, then # creating a VEVENT with RECURRENCE-ID matching the RDATE, except the # RECURRENCE-ID is in UTC, as is the modifications DTSTART. self.Import(self.view, u'oracle_mod.ics') master = pim.EventStamp(sharing.findUID(self.view, 'abbfc510-4d8f-11db-c525-001346a711f0')) modTime = datetime.datetime(2006, 9, 29, 13, tzinfo=self.utc) changed = master.getRecurrenceID(modTime) self.assert_(changed is not None) self.assertEqual(changed.itsItem.displayName, "Modification title changed") # test that a few of the custom fields were preserved when exporting vcalendar = getVObjectData(self.view, [master.itsItem]) self.assertEqual(vcalendar.vevent.organizer.params['X-ORACLE-GUID'][0], '07FC24E37F395815E0405794071A700C') self.assertEqual(vcalendar.vevent.created.value, '20060926T202203Z')
def _testImportOracleModification(self): # XXX this test is broken # switch to no-timezones mode schema.ns('osaf.pim', self.view).TimezonePrefs.showUI = False # Oracle modifies recurring events by first, if the time changed, adding # an EXDATE for the old time plus an RDATE for the new time, then # creating a VEVENT with RECURRENCE-ID matching the RDATE, except the # RECURRENCE-ID is in UTC, as is the modifications DTSTART. self.Import(self.view, u'oracle_mod.ics') master = pim.EventStamp( sharing.findUID(self.view, 'abbfc510-4d8f-11db-c525-001346a711f0')) modTime = datetime.datetime(2006, 9, 29, 13, tzinfo=self.utc) changed = master.getRecurrenceID(modTime) self.assert_(changed is not None) self.assertEqual(changed.itsItem.displayName, "Modification title changed") # test that a few of the custom fields were preserved when exporting vcalendar = getVObjectData(self.view, [master.itsItem]) self.assertEqual(vcalendar.vevent.organizer.params['X-ORACLE-GUID'][0], '07FC24E37F395815E0405794071A700C') self.assertEqual(vcalendar.vevent.created.value, '20060926T202203Z')
def testImportRecurrenceAndTriageStatus(self): self.Import(self.view, u'Recurrence.ics') event = pim.EventStamp( sharing.findUID(self.view, '5B30A574-02A3-11DA-AA66-000A95DA3228')) # test triage of imported recurring event: Bug 9414, there should be a # modification for the master triaged DONE in the DONE section. # Doing an updateTriageStatus should cause that modification to go # away firstOccurrence = event.getFirstOccurrence() self.assertEqual(firstOccurrence.modificationFor, event.itsItem) ts = firstOccurrence.itsItem._triageStatus sts = getattr(firstOccurrence.itsItem, '_sectionTriageStatus', ts) self.assertEqual(ts, pim.TriageEnum.done) self.assertEqual(sts, pim.TriageEnum.done) event.updateTriageStatus() self.assertEqual(firstOccurrence.modificationFor, None) self.assertEqual(firstOccurrence.itsItem._triageStatus, pim.TriageEnum.done) sts = getattr(firstOccurrence.itsItem, '_sectionTriageStatus', None) self.assertEqual(sts, None)
def testImportRecurrenceAndTriageStatus(self): self.Import(self.view, u'Recurrence.ics') event = pim.EventStamp(sharing.findUID(self.view, '5B30A574-02A3-11DA-AA66-000A95DA3228')) # test triage of imported recurring event: Bug 9414, there should be a # modification for the master triaged DONE in the DONE section. # Doing an updateTriageStatus should cause that modification to go # away firstOccurrence = event.getFirstOccurrence() self.assertEqual(firstOccurrence.modificationFor, event.itsItem) ts = firstOccurrence.itsItem._triageStatus sts = getattr(firstOccurrence.itsItem, '_sectionTriageStatus', ts) self.assertEqual(ts, pim.TriageEnum.done) self.assertEqual(sts, pim.TriageEnum.done) event.updateTriageStatus() self.assertEqual(firstOccurrence.modificationFor, None) self.assertEqual(firstOccurrence.itsItem._triageStatus, pim.TriageEnum.done) sts = getattr(firstOccurrence.itsItem, '_sectionTriageStatus', None) self.assertEqual(sts, None)
def testRDateOnly(self): self.Import(self.view, u'rdates.ics') event = pim.EventStamp(sharing.findUID(self.view, 'rdate_test')) self.failUnless(pim.has_stamp(event, pim.EventStamp)) self.assertEqual(len(event.rruleset.rdates), 3)
def testImportUnusualTzid(self): self.Import(self.view, u'UnusualTzid.ics') event = pim.EventStamp( sharing.findUID(self.view, '42583280-8164-11da-c77c-0011246e17f0')) mountain_time = self.view.tzinfo.getInstance('America/Denver') self.assertEqual(event.startTime.tzinfo, mountain_time)
def RoundTrip(self): view0 = self.views[0] view1 = self.views[1] coll0 = self.coll item = self.share0.contents.first() testUuid = item.itsUUID.str16() item.icalUID = testUuid self.assert_(not pim.has_stamp(item, sharing.SharedItem)) # Initial publish self.share0.create() view0.commit(); stats = self.share0.sync(); view0.commit() self.assert_(checkStats(stats, ({'added' : 2, 'modified' : 0, 'removed' : 0},)), "Sync operation mismatch") self.assert_(pim.has_stamp(coll0, sharing.SharedItem)) self.assert_(pim.has_stamp(item, sharing.SharedItem)) self.assert_(self.share0 in sharing.SharedItem(item).sharedIn) # Local modification only item.body = u"CHANGED" view0.commit(); stats = self.share0.sync(); view0.commit() self.assert_(checkStats(stats, ({'added' : 0, 'modified' : 0, 'removed' : 0}, {'added' : 0, 'modified' : 1, 'removed' : 0})), "Sync operation mismatch") ## Initial subscribe view1.commit(); stats = self.share1.sync(); view1.commit() self.assert_(checkStats(stats, ({'added' : 2, 'modified' : 0, 'removed' : 0}, {'added' : 0, 'modified' : 0, 'removed' : 0})), "Sync operation mismatch") # Verify items are imported for icalUID in self.icalUIDs: n = sharing.findUID(view1, icalUID) self.assertEqual(self.icalUIDs[icalUID], n.displayName) item1 = sharing.findUID(view1, testUuid) self.assert_(item1 in self.share1.contents) self.assert_(item1.body == u"CHANGED") self.assert_(pim.has_stamp(item1, sharing.SharedItem)) self.assert_(pim.has_stamp(self.share1.contents, sharing.SharedItem)) # XXX This fails, why? #self.assertEqual(self.share0.contents.itsUUID, #self.share1.contents.itsUUID) # Local and Remote modification, non-overlapping changes - all changes # apply item.body = u"body changed in 0" item1.displayName = u"displayName changed in 1" view0.commit(); stats = self.share0.sync(); view0.commit() self.assert_(checkStats(stats, ({'added' : 0, 'modified' : 0, 'removed' : 0}, {'added' : 0, 'modified' : 1, 'removed' : 0})), "Sync operation mismatch") view1.commit(); stats = self.share1.sync(); view1.commit() self.assert_(checkStats(stats, ({'added' : 0, 'modified' : 1, 'removed' : 0}, {'added' : 0, 'modified' : 1, 'removed' : 0})), "Sync operation mismatch") view0.commit(); stats = self.share0.sync(); view0.commit() self.assert_(checkStats(stats, ({'added' : 0, 'modified' : 1, 'removed' : 0}, {'added' : 0, 'modified' : 0, 'removed' : 0})), "Sync operation mismatch") self.assert_(item.displayName == "displayName changed in 1") self.assert_(item.body == "body changed in 0") self.assert_(item1.displayName == "displayName changed in 1") self.assert_(item1.body == "body changed in 0") self.share0.destroy() # clean up
def testMismatchedStartEndTimezones(self): self.Import(self.view, u'start_end_timezones.ics') event = pim.EventStamp( sharing.findUID(self.view, 'c1ea7e4c-c13f-11db-a49c-a07b7a7d67f5')) self.failUnlessEqual(event.startTime.tzinfo, self.view.tzinfo.floating)
def RoundTrip(self): view0 = self.views[0] view1 = self.views[1] coll0 = self.coll item = self.share0.contents.first() testUuid = item.itsUUID.str16() item.icalUID = testUuid self.assert_(not pim.has_stamp(item, sharing.SharedItem)) # Initial publish self.share0.create() view0.commit() stats = self.share0.sync() view0.commit() self.assert_( checkStats(stats, ({ 'added': 2, 'modified': 0, 'removed': 0 }, )), "Sync operation mismatch") self.assert_(pim.has_stamp(coll0, sharing.SharedItem)) self.assert_(pim.has_stamp(item, sharing.SharedItem)) self.assert_(self.share0 in sharing.SharedItem(item).sharedIn) # Local modification only item.body = u"CHANGED" view0.commit() stats = self.share0.sync() view0.commit() self.assert_( checkStats(stats, ({ 'added': 0, 'modified': 0, 'removed': 0 }, { 'added': 0, 'modified': 1, 'removed': 0 })), "Sync operation mismatch") ## Initial subscribe view1.commit() stats = self.share1.sync() view1.commit() self.assert_( checkStats(stats, ({ 'added': 2, 'modified': 0, 'removed': 0 }, { 'added': 0, 'modified': 0, 'removed': 0 })), "Sync operation mismatch") # Verify items are imported for icalUID in self.icalUIDs: n = sharing.findUID(view1, icalUID) self.assertEqual(self.icalUIDs[icalUID], n.displayName) item1 = sharing.findUID(view1, testUuid) self.assert_(item1 in self.share1.contents) self.assert_(item1.body == u"CHANGED") self.assert_(pim.has_stamp(item1, sharing.SharedItem)) self.assert_(pim.has_stamp(self.share1.contents, sharing.SharedItem)) # XXX This fails, why? #self.assertEqual(self.share0.contents.itsUUID, #self.share1.contents.itsUUID) # Local and Remote modification, non-overlapping changes - all changes # apply item.body = u"body changed in 0" item1.displayName = u"displayName changed in 1" view0.commit() stats = self.share0.sync() view0.commit() self.assert_( checkStats(stats, ({ 'added': 0, 'modified': 0, 'removed': 0 }, { 'added': 0, 'modified': 1, 'removed': 0 })), "Sync operation mismatch") view1.commit() stats = self.share1.sync() view1.commit() self.assert_( checkStats(stats, ({ 'added': 0, 'modified': 1, 'removed': 0 }, { 'added': 0, 'modified': 1, 'removed': 0 })), "Sync operation mismatch") view0.commit() stats = self.share0.sync() view0.commit() self.assert_( checkStats(stats, ({ 'added': 0, 'modified': 1, 'removed': 0 }, { 'added': 0, 'modified': 0, 'removed': 0 })), "Sync operation mismatch") self.assert_(item.displayName == "displayName changed in 1") self.assert_(item.body == "body changed in 0") self.assert_(item1.displayName == "displayName changed in 1") self.assert_(item1.body == "body changed in 0") self.share0.destroy() # clean up
def testMismatchedStartEndTimezones(self): self.Import(self.view, u'start_end_timezones.ics') event = pim.EventStamp(sharing.findUID(self.view, 'c1ea7e4c-c13f-11db-a49c-a07b7a7d67f5')) self.failUnlessEqual(event.startTime.tzinfo, self.view.tzinfo.floating)