Пример #1
0
    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
Пример #2
0
 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
Пример #3
0
 def setUp(self):
     super(TestEventIndexing, self).setUp()
     view = self.view
     self.tzInfoItem = TimeZoneInfo.get(view)
     # eventsInRange will treat all timezones as equivalent unless timezone
     # display is turned on
     self.tzprefs = schema.ns('osaf.pim', view).TimezonePrefs
     self.tzprefs.showUI = True
     
     self.pacific  = view.tzinfo.getInstance("US/Pacific")
     self.hawaii   = view.tzinfo.getInstance("US/Hawaii")
     self.eastern  = view.tzinfo.getInstance("US/Eastern")
     self.floating = view.tzinfo.floating
     
     self.midnight = datetime(2006, 9, 1, 0, 0, tzinfo=self.floating)
     
     self.easternEvent = self._createEvent(self.midnight.replace(tzinfo=
         self.eastern))
     self.pacificEvent = self._createEvent(self.midnight.replace(tzinfo=
         self.pacific))
     self.hawaiiEvent  = self._createEvent(self.midnight.replace(tzinfo=
         self.hawaii))
     
     self.floatingEvent = self._createEvent(datetime(2006, 9, 1, 1, 0,
                                                     tzinfo = self.floating))
def buildTZChoiceList(view, control, selectedTZ=None):
    """
    Take a wx.Choice control and a timezone to select.  Populate the control
    with the appropriate timezones, plus a More option, whose value is
    TIMEZONE_OTHER_FLAG.

    Default selection is view.tzinfo.default.
    
    """
    control.Clear()
    selectIndex = -1
    info = TimeZoneInfo.get(view)
    if selectedTZ is None:
        selectedTZ = olsonizeTzinfo(view, view.tzinfo.default)
    canonicalTimeZone = info.canonicalTimeZone(selectedTZ)

    # rebuild the list of choices
    for name, zone in info.iterTimeZones():
        if canonicalTimeZone == zone:
            selectIndex = control.Append(name, clientData=selectedTZ)
        else:
            control.Append(name, clientData=zone)

    # Always add the More option
    control.Append(_(u"More..."),
                   clientData=TIMEZONE_OTHER_FLAG)

    if selectIndex is -1:
        control.Insert(unicode(selectedTZ), 0, clientData=selectedTZ)
        selectIndex = 0
        
    if selectIndex != -1:
        control.Select(selectIndex)
    def testDefaultSettings(self):
        defaultTz = TimeZoneInfo.get(self.sandbox.itsView).default
        ROUND = 30

        # A new event, by default, has its startTime set to the current time
        # rounded to a 30-minute boundary
        start = datetime.now(defaultTz)
        event = Calendar.CalendarEvent(itsParent=self.sandbox,
                                       anyTime=False,
                                       allDay=False)
        end = datetime.now(defaultTz)

        # Check that it falls within 30 minutes of now
        self.failUnless(start - timedelta(minutes=ROUND) <= event.startTime
                        and event.startTime <= end + timedelta(minutes=ROUND))

        # Check that the correct rounding occurred
        self.failUnlessEqual(event.startTime.second, 0)
        self.failUnlessEqual(event.startTime.microsecond, 0)
        self.failUnlessEqual(event.startTime.minute % ROUND, 0)

        # Make sure it's in the right timezone
        self.failUnlessEqual(event.startTime.tzinfo, defaultTz)

        # Lastly, check the dates if possible
        if start.date() == end.date():
            self.failUnlessEqual(start.date(), event.startTime.date())

        self.failUnlessEqual(event.effectiveStartTime, event.startTime)
        self.failUnlessEqual(event.effectiveEndTime, event.endTime)
Пример #6
0
    def testDefaultSettings(self):
        defaultTz = TimeZoneInfo.get(self.sandbox.itsView).default
        ROUND = 30

        # A new event, by default, has its startTime set to the current time
        # rounded to a 30-minute boundary
        start = datetime.now(defaultTz)
        event = Calendar.CalendarEvent(itsParent=self.sandbox, anyTime=False, allDay=False)
        end = datetime.now(defaultTz)

        # Check that it falls within 30 minutes of now
        self.failUnless(
            start - timedelta(minutes=ROUND) <= event.startTime and event.startTime <= end + timedelta(minutes=ROUND)
        )

        # Check that the correct rounding occurred
        self.failUnlessEqual(event.startTime.second, 0)
        self.failUnlessEqual(event.startTime.microsecond, 0)
        self.failUnlessEqual(event.startTime.minute % ROUND, 0)

        # Make sure it's in the right timezone
        self.failUnlessEqual(event.startTime.tzinfo, defaultTz)

        # Lastly, check the dates if possible
        if start.date() == end.date():
            self.failUnlessEqual(start.date(), event.startTime.date())

        self.failUnlessEqual(event.effectiveStartTime, event.startTime)
        self.failUnlessEqual(event.effectiveEndTime, event.endTime)
 def __init__(self, view, grid):
     wx.grid.PyGridTableBase.__init__(self)
     self.view = view
     self.grid = grid
     self.info = TimeZoneInfo.get(self.view)
     self.changed = {}
     self.unexpandedSize = -1
     self.setRows()
Пример #8
0
def initTimezone(options, view):

    from osaf.pim.calendar.TimeZone import TimeZoneInfo, ontzchange

    repository = view.repository

    view.tzinfo.ontzchange = ontzchange
    if repository is not None:
        repository.ontzchange = ontzchange

    default = options.timezone or TimeZoneInfo.get(view).default
    if default != view.tzinfo.floating:
        view.tzinfo.default = default
        if repository is not None:
            repository.timezone = default
Пример #9
0
def initTimezone(options, view):

    from osaf.pim.calendar.TimeZone import TimeZoneInfo, ontzchange

    repository = view.repository

    view.tzinfo.ontzchange = ontzchange
    if repository is not None:
        repository.ontzchange = ontzchange

    default = options.timezone or TimeZoneInfo.get(view).default
    if default != view.tzinfo.floating:
        view.tzinfo.default = default
        if repository is not None:
            repository.timezone = default
Пример #10
0
    def startTest(self):

        # make user collection, since only user
        # collections can be displayed as a calendar
        col = QAUITestAppLib.UITestItem("Collection", self.logger)

        # switch to calendar view
        testView = QAUITestAppLib.UITestView(self.logger)
        testView.SwitchToCalView()

        calendarBlock = getattr(self.app_ns, "MainCalendarControl")

        # Find the "canonical timezone" to use in test comparisons
        view = self.app_ns.itsView
        info = TimeZoneInfo.get(view)
        originalTz = info.canonicalTimeZone(view.tzinfo.default).tzid
        switchTz = "Pacific/Honolulu"

        # Enable timezones so that we can switch from the UI
        self.app_ns.root.EnableTimezones()

        # Create a new event, which should inherit the default tz
        timezoneEvent = QAUITestAppLib.UITestItem("Event", self.logger)

        # Test that the new event has indeed inherited the default tz
        timezoneEvent.CheckDisplayedValues(EditTimeZone=(True, originalTz))

        # Change the timezone to Pacific/Honolulu
        QAUITestAppLib.SetChoice(calendarBlock.widget.tzChoice, switchTz)

        # Test that the event timezone hasn't changed
        timezoneEvent.CheckDisplayedValues(EditTimeZone=(True, originalTz))

        # Test that the default timezone has switched
        self.logger.startAction("Verify timezone switched")
        if view.tzinfo.setDefault(view.tzinfo.getInstance(switchTz)):
            self.logger.endAction(True, "Timezone switched")
        else:
            self.logger.endAction(False, "Timezone failed to switch")

        # @@@ More interesting tests could be added here

        # Switch back to original timezone
        QAUITestAppLib.SetChoice(calendarBlock.widget.tzChoice, originalTz)
Пример #11
0
    def startTest(self):
        
        # make user collection, since only user
        # collections can be displayed as a calendar
        col = QAUITestAppLib.UITestItem("Collection", self.logger)
        
        # switch to calendar view
        testView = QAUITestAppLib.UITestView(self.logger)
        testView.SwitchToCalView()       

        calendarBlock = getattr(self.app_ns, "MainCalendarControl")
    
        # Find the "canonical timezone" to use in test comparisons
        view = self.app_ns.itsView
        info = TimeZoneInfo.get(view)
        originalTz = info.canonicalTimeZone(view.tzinfo.default).tzid
        switchTz = "Pacific/Honolulu"
    
        # Enable timezones so that we can switch from the UI
        self.app_ns.root.EnableTimezones()
    
        # Create a new event, which should inherit the default tz 
        timezoneEvent = QAUITestAppLib.UITestItem("Event", self.logger)
    
        # Test that the new event has indeed inherited the default tz
        timezoneEvent.CheckDisplayedValues(EditTimeZone=(True, originalTz))
    
        # Change the timezone to Pacific/Honolulu
        QAUITestAppLib.SetChoice(calendarBlock.widget.tzChoice, switchTz)
    
        # Test that the event timezone hasn't changed
        timezoneEvent.CheckDisplayedValues(EditTimeZone=(True, originalTz))
    
        # Test that the default timezone has switched
        self.logger.startAction("Verify timezone switched")
        if view.tzinfo.setDefault(view.tzinfo.getInstance(switchTz)):
            self.logger.endAction(True, "Timezone switched")
        else:
            self.logger.endAction(False, "Timezone failed to switch")
    
        # @@@ More interesting tests could be added here
    
        # Switch back to original timezone
        QAUITestAppLib.SetChoice(calendarBlock.widget.tzChoice, originalTz)