def testTimezoneConversion(self):
        """
        Floating events should be converted to non-floating when turning on
        show timezones.
        
        """
        view = self.view
        view.tzinfo.setDefault(view.tzinfo.getInstance("America/Los_Angeles"))
        tzprefs = schema.ns('osaf.pim', self.view).TimezonePrefs
        tzprefs.showUI = False

        start = datetime(2007, 1, 17, 13, tzinfo=view.tzinfo.floating)
        event = CalendarEvent(None, itsView=view)
        event.startTime = start

        tzprefs.showUI = True

        self.failUnlessEqual(event.startTime.tzinfo.timezone.getID(),
                             "America/Los_Angeles")
示例#2
0
    def testTimezoneConversion(self):
        """
        Floating events should be converted to non-floating when turning on
        show timezones.
        
        """
        view = self.view
        view.tzinfo.setDefault(view.tzinfo.getInstance("America/Los_Angeles"))
        tzprefs = schema.ns('osaf.pim', self.view).TimezonePrefs
        tzprefs.showUI = False
        
        start = datetime(2007, 1, 17, 13, tzinfo=view.tzinfo.floating)
        event = CalendarEvent(None, itsView=view)
        event.startTime = start
        
        tzprefs.showUI = True        

        self.failUnlessEqual(event.startTime.tzinfo.timezone.getID(),
                             "America/Los_Angeles")
    def testChange(self):
        from osaf import sharing
        from osaf.pim import ListCollection

        self.tzprefs.showUI = False

        gayParee = self.view.tzinfo.getInstance("Europe/Paris")

        master = CalendarEvent(itsView=self.view,
                               anyTime=False,
                               startTime=datetime(
                                   2007,
                                   2,
                                   7,
                                   11,
                                   30,
                                   tzinfo=self.view.tzinfo.floating),
                               duration=timedelta(hours=1))

        master.rruleset = RecurrenceRuleSet(
            itsView=self.view,
            rrules=[RecurrenceRule(itsView=self.view, freq='daily')])

        ordinary = CalendarEvent(itsView=self.view,
                                 anyTime=False,
                                 startTime=datetime(
                                     2007,
                                     2,
                                     7,
                                     11,
                                     30,
                                     tzinfo=self.view.tzinfo.floating),
                                 duration=timedelta(hours=1))

        sharedFloating = CalendarEvent(itsView=self.view,
                                       anyTime=False,
                                       startTime=datetime(
                                           2002,
                                           12,
                                           22,
                                           tzinfo=self.view.tzinfo.floating))
        share = sharing.Share(itsView=self.view, hidden=False)
        item = sharing.SharedItem(sharedFloating)
        item.add()
        item.sharedIn = item.shares = [share]

        nonFloatingOccurrence = master.getNextOccurrence(
            after=datetime(2007, 5, 2, tzinfo=self.view.tzinfo.floating))

        nonFloatingOccurrence.changeThis(
            EventStamp.startTime.name,
            nonFloatingOccurrence.startTime.replace(tzinfo=gayParee))

        titleMod = nonFloatingOccurrence.getNextOccurrence()
        titleMod.itsItem.summary = "yabba dabba doo"

        self.tzprefs.showUI = True

        tzItem = TimeZoneInfo.get(self.view)

        # Make sure that floating is no longer the default
        self.failIfEqual(self.view.tzinfo.default, self.view.tzinfo.floating)
        self.failIfEqual(tzItem.default, self.view.tzinfo.floating)
        self.failUnlessEqual(tzItem.default, self.view.tzinfo.default)

        # Make sure the ordinary and master events acquired the default tz
        self.failUnlessEqual(ordinary.startTime.tzinfo,
                             self.view.tzinfo.default)
        self.failUnlessEqual(master.startTime.tzinfo, self.view.tzinfo.default)

        # Make sure the non-floating occurrence didn't have its tz changed
        self.failUnlessEqual(nonFloatingOccurrence.startTime.tzinfo, gayParee)

        # Check the master's occurrences ...
        for event in map(EventStamp, master.occurrences):
            # Everything but the modification we just made should have
            # the default timezone set for startTime ...
            if event != nonFloatingOccurrence:
                self.failUnlessEqual(event.startTime.tzinfo,
                                     self.view.tzinfo.default)

            # and recurrenceIDs should always have the master's tzinfo
            self.failUnlessEqual(event.recurrenceID.tzinfo,
                                 self.view.tzinfo.default)

        # ... and the shared item's tzinfo should not have changed
        self.failUnlessEqual(sharedFloating.startTime.tzinfo,
                             self.view.tzinfo.floating)

        self.tzprefs.showUI = False
        self.failUnlessEqual(tzItem.default, self.view.tzinfo.floating)
        self.failIfEqual(self.view.tzinfo.floating, self.view.tzinfo.default)
示例#4
0
    def testChange(self):
        from osaf import sharing
        from osaf.pim import ListCollection
        
        self.tzprefs.showUI = False
        
        gayParee = self.view.tzinfo.getInstance("Europe/Paris")
        
        master = CalendarEvent(itsView=self.view, anyTime=False,
                    startTime=datetime(2007, 2, 7, 11, 30,
                                      tzinfo=self.view.tzinfo.floating),
                    duration=timedelta(hours=1))

        master.rruleset = RecurrenceRuleSet(
            itsView=self.view, rrules=[
                RecurrenceRule(itsView=self.view,freq='daily')
            ]
        )

        ordinary = CalendarEvent(itsView=self.view, anyTime=False,
                    startTime=datetime(2007, 2, 7, 11, 30,
                                      tzinfo=self.view.tzinfo.floating),
                    duration=timedelta(hours=1))
                    
        sharedFloating = CalendarEvent(itsView=self.view, anyTime=False,
                   startTime=datetime(2002, 12, 22, tzinfo=self.view.tzinfo.floating))
        share = sharing.Share(itsView=self.view, hidden=False)
        item = sharing.SharedItem(sharedFloating)
        item.add()
        item.sharedIn = item.shares = [share]
        
        nonFloatingOccurrence = master.getNextOccurrence(
            after=datetime(2007, 5, 2, tzinfo=self.view.tzinfo.floating))

        
        nonFloatingOccurrence.changeThis(
            EventStamp.startTime.name,
            nonFloatingOccurrence.startTime.replace(tzinfo=gayParee)
        )

        titleMod = nonFloatingOccurrence.getNextOccurrence()
        titleMod.itsItem.summary = "yabba dabba doo"
                
        self.tzprefs.showUI = True
        
        tzItem = TimeZoneInfo.get(self.view)
        
        # Make sure that floating is no longer the default
        self.failIfEqual(self.view.tzinfo.default, self.view.tzinfo.floating)
        self.failIfEqual(tzItem.default, self.view.tzinfo.floating)
        self.failUnlessEqual(tzItem.default, self.view.tzinfo.default)
        
        # Make sure the ordinary and master events acquired the default tz
        self.failUnlessEqual(ordinary.startTime.tzinfo, self.view.tzinfo.default)
        self.failUnlessEqual(master.startTime.tzinfo, self.view.tzinfo.default)
        
        # Make sure the non-floating occurrence didn't have its tz changed
        self.failUnlessEqual(nonFloatingOccurrence.startTime.tzinfo, gayParee)
        
        # Check the master's occurrences ...
        for event in map(EventStamp, master.occurrences):
            # Everything but the modification we just made should have
            # the default timezone set for startTime ...
            if event != nonFloatingOccurrence:
                self.failUnlessEqual(event.startTime.tzinfo, self.view.tzinfo.default)
                                     
            # and recurrenceIDs should always have the master's tzinfo
            self.failUnlessEqual(event.recurrenceID.tzinfo, self.view.tzinfo.default)

        # ... and the shared item's tzinfo should not have changed
        self.failUnlessEqual(sharedFloating.startTime.tzinfo,
                             self.view.tzinfo.floating)

        self.tzprefs.showUI = False
        self.failUnlessEqual(tzItem.default, self.view.tzinfo.floating)
        self.failIfEqual(self.view.tzinfo.floating, self.view.tzinfo.default)
示例#5
0
    def testBug2288(self):
        """ regression test for bug 2288 """
        import osaf.pim.tests.GenerateItems as GenerateItems

        self.loadParcels(
            ['parcel:osaf.pim.calendar']
        )

        view = self.rep.view
        GenerateItems.GenerateItems(view, 20, GenerateItems.GenerateCalendarEvent)
        view.commit()

        queryString = "for i inevery '//parcels/osaf/pim/calendar/CalendarEventMixin' where i.hasLocalAttributeValue('reminderTime')"
        p = self.rep.findPath('//Queries')
        k = self.rep.findPath('//Schema/Core/Query')
        q = Query.Query('bug2288Query', p, k, queryString)
        view.commit()

        for i in q.resultSet:
            print i, hasattr(i, 'reminderTime'), i.hasLocalAttributeValue('reminderTime')

        k = self.rep.findPath('//parcels/notification/NotificationItem')
        notify_client = NotificationItem.NotificationItem('testNotifier', self.rep, k)
        monitor_client = NotificationItem.NotificationItem('testMonitorNotifier', self.rep, k)
        item = notify_client

        q.subscribe(notify_client, 'handle', False, True)
        q.subscribe(monitor_client, 'handle', True, False)
        ce = q.resultSet.first()
        self.rep.commit()

        # add the reminderTime attribute
        from datetime import datetime
        ce.reminderTime = datetime.now()
        (added, removed) = monitor_client.action
        self.assert_(len(added) == 1 and len(removed) == 0)
        print len(q.resultSet)
        self.rep.commit()
        (added, removed) = notify_client.action
        self.assert_(len(added) == 1 and len(removed) == 0)
        print len(q.resultSet)
        
        # create a new event.  without the reminderTime attribute
        from osaf.pim.calendar.Calendar import CalendarEvent
        monitor_client.action = ([],[])
        ev = CalendarEvent("test event", view=self.rep.view)
        (added, removed) = monitor_client.action
        self.assert_(len(added) == 0 and len(removed) == 1)
        self.rep.commit()
        (added, removed) = notify_client.action
        self.assert_(len(added) == 0 and len(removed) == 0)

        # add the existing reminderTime attribute
        monitor_client.action = ([],[])
        ev.reminderTime = datetime.now()
        (added, removed) = monitor_client.action
        self.assert_(len(added) == 1 and len(removed) == 0)
        self.rep.commit()
        (added, removed) = notify_client.action
        self.assert_(len(added) == 1 and len(removed) == 0)

        # remove the reminderTime attribute
        monitor_client.action = ([],[])
        #@@@ Monitor doesn't get called for delattr
        delattr(ev, 'reminderTime')
        (added, removed) = monitor_client.action
        print "Monitor: ", added, removed
#        self.assert_(len(added) == 0 and len(removed) == 1)
        self.rep.commit()
        (added, removed) = notify_client.action
        self.assert_(len(added) == 0 and len(removed) == 1)