Example #1
0
def sendMail(type, logName):
    mail = QAUITestAppLib.UITestItem("MailMessage", None)

    pt = uw("Performance Test")

    attrs = {
       "displayName": u"[%s] %s" % (getCounterNext(), pt),
       "toAddress": "*****@*****.**",
       "body": "%s " % pt * 15,
    }


    if "E" in type:
        mail.StampAsCalendarEvent(True, timeInfo=False)

        attrs["startDate"] ="3/2/2007"
        attrs["startTime"] = "6:00 PM"
        attrs["endTime"] = "7:00PM"
        attrs["location"] = uw("Performance Test Location")
        attrs["status"] = "FYI"

    if "T" in type:
        mail.StampAsTask(True, timeInfo=False)

    mail.SetAttr(**attrs)

    logger.Start(logName)
    mail.SendMail(timeInfo=False)
    logger.Stop()

    # Test Phase: Verification
    logger.SetChecked(True)
    logger.Report(logName)
Example #2
0
    def testLocations(self):
        """ Simple test for the Locations Factory - getLocation """

        self.loadParcel("osaf.pim.calendar")

        # Test the globals
        locationsPath = Path('//parcels/osaf/pim/calendar')
        view = self.view

        self.assertEqual(Calendar.Location.getKind(view),
                         view.find(Path(locationsPath, 'Location')))

        locationNames = [uw("Alderon"), uw("Atlantis"), uw("Arcadia")]

        # Construct sample items
        for loc in locationNames:
            # use the factory to create or lookup an item
            aRoom = Calendar.Location.getLocation (view, loc)
            # test that convert to string yeilds the name of the location
            self.assertEqual (loc, unicode (aRoom))

        # call the factory on the last name again, to ensure reuse
        sameLocation = Calendar.Location.getLocation (view, locationNames [-1])
        self.assert_ (aRoom is sameLocation, "Location factory failed to return the same location!")

        # Double check kinds
        self.assertEqual(aRoom.itsKind, Calendar.Location.getKind(view))

        # Literal properties
        aRoom.displayName = uw("A Nice Place") # change the Location name
        # make sure we can get the name, and find it by that name
        sameLocation = Calendar.Location.getLocation (view, aRoom.displayName)
        self.assert_ (aRoom is sameLocation, "Location factory failed to return an identical location!")
    def setUp(self):
        super(InOutCollectionTests, self).setUp()

        self.inCol  = schema.ns('osaf.pim', self.view).inCollection
        self.outCol = schema.ns('osaf.pim', self.view).outCollection
        self.meCol  = schema.ns("osaf.pim", self.view).meEmailAddressCollection

        self.m1 = MailMessage(itsView=self.view)
        self.m2 = MailMessage(itsView=self.view)
        self.m3 = MailMessage(itsView=self.view)
        self.m4 = MailMessage(itsView=self.view)
        self.m5 = MailMessage(itsView=self.view)
        self.m6 = MailMessage(itsView=self.view)
        self.m7 = MailMessage(itsView=self.view)

        self.e1 = EmailAddress.getEmailAddress(self.view, "*****@*****.**", 
                                               uw("Test User1"))

        self.e2 = EmailAddress.getEmailAddress(self.view, u"*****@*****.**",
                                               uw("Test User2"))

        self.e3 = EmailAddress.getEmailAddress(self.view, u"*****@*****.**",
                                               uw("Test User3"))

        # (Differs from e3 only by case of the emailAddress)
        self.e4 = EmailAddress.getEmailAddress(self.view,
                                               self.e3.emailAddress.upper(),
                                               self.e3.fullName)

        self.imapAcct = IMAPAccount(itsView=self.view)
        self.smtpAcct = SMTPAccount(itsView=self.view)
Example #4
0
    def testFilteredDelete(self):
        """
        Test deleting an item from a FilteredCollection by updating an
        attribute of an item in the source.
        """
        k1 = KindCollection(itsView=self.view,
                            kind=self.i.itsKind)
        f2 = FilteredCollection(itsView=self.view,
                                source=k1,
                                filterExpression=u"view[uuid].hasLocalAttributeValue('label')",
                                filterAttributes=["label"])
        nh3 = NotifyHandler("nh3", itsView=self.view)

        self.view.watchCollectionQueue(self.nh2, k1, 'queuedChange')
        self.view.watchCollectionQueue(nh3, f2, 'queuedChange')

        self.i.label = uw("xxx")
        print nh3.log
        self.view.dispatchQueuedNotifications()

        changed = False
        print nh3.log
        for i in nh3.log[::-1]:
            if i[0] == "changed" and i[1] is f2 and i[3] == self.i.itsUUID:
                changed = True
                break
        self.failUnless(changed)
        self.assertEqual(self.i.label,uw("xxx"))

        delattr(self.i,"label")
        self.view.dispatchQueuedNotifications()

        self.failUnless(nh3.checkLog("remove", f2, self.i,-2))
        self.failUnless(self.nh2.checkLog("changed", k1, self.i))
    def setUp(self):
        super(InOutCollectionTests, self).setUp()

        self.inCol = schema.ns('osaf.pim', self.view).inCollection
        self.outCol = schema.ns('osaf.pim', self.view).outCollection
        self.meCol = schema.ns("osaf.pim", self.view).meEmailAddressCollection

        self.m1 = MailMessage(itsView=self.view)
        self.m2 = MailMessage(itsView=self.view)
        self.m3 = MailMessage(itsView=self.view)
        self.m4 = MailMessage(itsView=self.view)
        self.m5 = MailMessage(itsView=self.view)
        self.m6 = MailMessage(itsView=self.view)
        self.m7 = MailMessage(itsView=self.view)

        self.e1 = EmailAddress.getEmailAddress(self.view, "*****@*****.**",
                                               uw("Test User1"))

        self.e2 = EmailAddress.getEmailAddress(self.view, u"*****@*****.**",
                                               uw("Test User2"))

        self.e3 = EmailAddress.getEmailAddress(self.view, u"*****@*****.**",
                                               uw("Test User3"))

        # (Differs from e3 only by case of the emailAddress)
        self.e4 = EmailAddress.getEmailAddress(self.view,
                                               self.e3.emailAddress.upper(),
                                               self.e3.fullName)

        self.imapAcct = IMAPAccount(itsView=self.view)
        self.smtpAcct = SMTPAccount(itsView=self.view)
Example #6
0
    def startTest(self):
        
        today = strftime('%m/%d/%Y',localtime())
    

        view = QAUITestAppLib.UITestView(self.logger)

        
        #Create a collection and select it
        collection = QAUITestAppLib.UITestItem("Collection", self.logger)
        collection.SetDisplayName(uw("stacked"))
        sidebar = self.app_ns.sidebar
        QAUITestAppLib.scripting.User.emulate_sidebarClick(sidebar, uw("stacked"))
        
        # Make sure we are in calendar view, need to do this AFTER creating a
        # collection, or we might be in the dashboard
        view.SwitchToCalView()
        
        #make sure we are on current week
        view.GoToToday()
        
        # creation
        for i in range(10):
            eventName = uw('Stacked Event %d' % i)
            event = QAUITestAppLib.UITestItem("Event", self.logger)
            
            #action
            event.SetAttr(displayName=eventName, startDate=today, startTime="12:00 PM", body=uw("Stacked event test"))
            
            #verification
            event.Check_DetailView({"displayName":eventName,"startDate":today,"endDate":today,"startTime":"12:00 PM","body":uw("Stacked event test")})
Example #7
0
    def testFilteredStack(self):
        """
        Test collections stacked on top of each other
        """
        k = KindCollection(itsView=self.view,
                           kind=self.i.itsKind)

        f = FilteredCollection(itsView=self.view,
                               source=k,
                               filterExpression=u"len(view[uuid].label) > 3",
                               filterAttributes=["label"])

        l = ListCollection(itsView=self.view)

        u = UnionCollection(itsView=self.view)
        self.view.watchCollectionQueue(self.nh, u, 'queuedChange')

        u.addSource(f)
        u.addSource(l)
        self.view.dispatchQueuedNotifications()

        self.i.label = uw("abcd")
        self.view.dispatchQueuedNotifications()
        self.failUnless(self.nh.checkLog('add', u, self.i))

        self.i.label = uw("defg")
        self.view.dispatchQueuedNotifications()
        self.failUnless(self.nh.checkLog('changed', u, self.i))

        self.i.label = uw("a")
        self.view.dispatchQueuedNotifications()
        self.failUnless(self.nh.checkLog('remove', u, self.i))
def createAccounts():
    ap = QAUITestAppLib.UITestAccounts(logger)

    pSMTP = uw("Personal SMTP")
    pIMAP = uw("Personal IMAP")
    pEMAIL = "*****@*****.**"
    pNAME = uw("Demo One")

    # action
    ap.Open()  # first, open the accounts dialog window

    ap.GetDefaultAccount("OUTGOING")
    ap.TypeValue(
        "displayName",
        pSMTP)  # type the following values into their apporpriate fields
    ap.TypeValue("host", "smtp.osafoundation.org")
    ap.SelectValue("security", 'TLS')  # select the TLS radio button
    ap.ToggleValue("authentication",
                   True)  # turn on the authentication checkbox
    ap.TypeValue("port", '587')
    ap.TypeValue("email", pEMAIL)
    ap.TypeValue('username', 'demo1')
    ap.TypeValue('password', 'ad3leib5')

    ap.GetDefaultAccount("INCOMING")
    ap.TypeValue("displayName", pIMAP)
    ap.TypeValue("email", pEMAIL)
    ap.TypeValue("name", pNAME)
    ap.TypeValue("host", "imap.osafoundation.org")
    ap.TypeValue("username", "demo1")
    ap.TypeValue("password", "ad3leib5")
    ap.SelectValue("security", "SSL")
    ap.SelectValue("protocol", "IMAP")

    ap.Ok()
Example #9
0
def createAccounts():
    ap = QAUITestAppLib.UITestAccounts(logger)

    pSMTP   = uw("Personal SMTP")
    pIMAP   = uw("Personal IMAP")
    pEMAIL  = "*****@*****.**"
    pNAME   = uw("Demo One")

    # action
    ap.Open() # first, open the accounts dialog window

    ap.GetDefaultAccount("OUTGOING")
    ap.TypeValue("displayName", pSMTP) # type the following values into their apporpriate fields
    ap.TypeValue("host","smtp.osafoundation.org")
    ap.SelectValue("security",  'TLS') # select the TLS radio button
    ap.ToggleValue("authentication", True) # turn on the authentication checkbox
    ap.TypeValue("port", '587')
    ap.TypeValue("email", pEMAIL)
    ap.TypeValue('username', 'demo1')
    ap.TypeValue('password', 'ad3leib5')

    ap.GetDefaultAccount("INCOMING")
    ap.TypeValue("displayName", pIMAP)
    ap.TypeValue("email", pEMAIL)
    ap.TypeValue("name", pNAME)
    ap.TypeValue("host", "imap.osafoundation.org")
    ap.TypeValue("username", "demo1")
    ap.TypeValue("password", "ad3leib5")
    ap.SelectValue("security", "SSL")
    ap.SelectValue("protocol", "IMAP")

    ap.Ok()
    def testFilteredDelete(self):
        """
        Test deleting an item from a FilteredCollection by updating an
        attribute of an item in the source.
        """
        k1 = KindCollection(itsView=self.view, kind=self.i.itsKind)
        f2 = FilteredCollection(
            itsView=self.view,
            source=k1,
            filterExpression=u"view[uuid].hasLocalAttributeValue('label')",
            filterAttributes=["label"])
        nh3 = NotifyHandler("nh3", itsView=self.view)

        self.view.watchCollectionQueue(self.nh2, k1, 'queuedChange')
        self.view.watchCollectionQueue(nh3, f2, 'queuedChange')

        self.i.label = uw("xxx")
        print nh3.log
        self.view.dispatchQueuedNotifications()

        changed = False
        print nh3.log
        for i in nh3.log[::-1]:
            if i[0] == "changed" and i[1] is f2 and i[3] == self.i.itsUUID:
                changed = True
                break
        self.failUnless(changed)
        self.assertEqual(self.i.label, uw("xxx"))

        delattr(self.i, "label")
        self.view.dispatchQueuedNotifications()

        self.failUnless(nh3.checkLog("remove", f2, self.i, -2))
        self.failUnless(self.nh2.checkLog("changed", k1, self.i))
    def testFilteredStack(self):
        """
        Test collections stacked on top of each other
        """
        k = KindCollection(itsView=self.view, kind=self.i.itsKind)

        f = FilteredCollection(itsView=self.view,
                               source=k,
                               filterExpression=u"len(view[uuid].label) > 3",
                               filterAttributes=["label"])

        l = ListCollection(itsView=self.view)

        u = UnionCollection(itsView=self.view)
        self.view.watchCollectionQueue(self.nh, u, 'queuedChange')

        u.addSource(f)
        u.addSource(l)
        self.view.dispatchQueuedNotifications()

        self.i.label = uw("abcd")
        self.view.dispatchQueuedNotifications()
        self.failUnless(self.nh.checkLog('add', u, self.i))

        self.i.label = uw("defg")
        self.view.dispatchQueuedNotifications()
        self.failUnless(self.nh.checkLog('changed', u, self.i))

        self.i.label = uw("a")
        self.view.dispatchQueuedNotifications()
        self.failUnless(self.nh.checkLog('remove', u, self.i))
def sendMail(type, logName):
    mail = QAUITestAppLib.UITestItem("MailMessage", None)

    pt = uw("Performance Test")

    attrs = {
        "displayName": u"[%s] %s" % (getCounterNext(), pt),
        "toAddress": "*****@*****.**",
        "body": "%s " % pt * 15,
    }

    if "E" in type:
        mail.StampAsCalendarEvent(True, timeInfo=False)

        attrs["startDate"] = "3/2/2007"
        attrs["startTime"] = "6:00 PM"
        attrs["endTime"] = "7:00PM"
        attrs["location"] = uw("Performance Test Location")
        attrs["status"] = "FYI"

    if "T" in type:
        mail.StampAsTask(True, timeInfo=False)

    mail.SetAttr(**attrs)

    logger.Start(logName)
    mail.SendMail(timeInfo=False)
    logger.Stop()

    # Test Phase: Verification
    logger.SetChecked(True)
    logger.Report(logName)
    def startTest(self):

        START_DATE = 0
        START_TIME = 1
        END_DATE = 2
        END_TIME = 3
        TIMEZONE = 4

        # tests that need to be added:
        #     week to week transistions
        #     non-pacific time zones
        #     other locales

        dateValues = {
            'us': [  # year end transistion
                ('12/31/04', '11:30 PM', '1/1/05', '12:30 AM',
                 'America/Chicago'),
                # leap year (feb has 29 days)
                ('2/28/04', '11:30 PM', '2/29/04', '12:30 AM',
                 'America/Chicago'),
                # leap year (feb has 29 days)
                ('2/29/04', '11:30 PM', '3/1/04', '12:30 AM', 'America/Chicago'
                 ),
                # Daylight savings time start
                ('4/2/06', '1:00 AM', '4/2/06', '3:00 AM', 'America/Chicago'),
                # Daylight savings time end
                ('10/29/06', '2:00 AM', '10/29/06', '1:00 AM',
                 'America/Chicago'),
            ],
        }

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

        # creation
        event = QAUITestAppLib.UITestItem("Event", self.logger)

        for locale in dateValues:
            testItems = dateValues[locale]

            for test in testItems:
                s = uw('%s %s :: %s %s :: %s' % test)

                event.SetAttr(displayName=uw("Test"),
                              startDate=test[START_DATE],
                              startTime=test[START_TIME],
                              body=s,
                              timeZone=test[TIMEZONE])

                event.Check_DetailView({
                    "displayName": uw("Test"),
                    "startDate": test[START_DATE],
                    "endDate": test[END_DATE],
                    "startTime": test[START_TIME],
                    "endTime": test[END_TIME],
                    "body": s,
                })
Example #14
0
 def startTest(self):
     
     note = QAUITestAppLib.UITestItem("Note", self.logger)
     
     # action
     note.SetAttr(displayName=uw("A note to myself about filing taxes"), body=uw("FILE TAXES!"))
     
     # verification
     note.Check_DetailView({"displayName":uw("A note to myself about filing taxes"),"body":uw("FILE TAXES!")})
    def startTest(self):

        # action
        col = QAUITestAppLib.UITestItem("Collection", self.logger)
        # verification
        col.Check_CollectionExistence("Untitled")

        # action
        col.SetDisplayName(uw("Meeting"))
        # verification
        col.Check_CollectionExistence(uw("Meeting"))

        # action
        note = QAUITestAppLib.UITestItem("Note", self.logger)
        note.AddCollection(uw("Meeting"))
        # verification
        note.Check_ItemInCollection(uw("Meeting"))

        # Bug 5803, make sure items in collections that change to not mine
        # are really not in the All collection, and similarly that events
        # created after the collection becomes not mine are truly not mine

        sidebar = QAUITestAppLib.App_ns.sidebar

        # select the Meeting collection
        scripting.User.emulate_sidebarClick(sidebar, uw('Meeting'))

        # Switch to the Calendar View
        QAUITestAppLib.App_ns.appbar.press("ApplicationBarEventButton")

        # ... idle() so the app can handle changes
        QAUITestAppLib.scripting.User.idle()

        beforeChangeEvent = QAUITestAppLib.UITestItem("Event", self.logger)
        beforeChangeEvent.AddCollection(uw("Meeting"))
        beforeChangeEvent.Check_ItemInCollection(uw("Meeting"),
                                                 expectedResult=True)
        beforeChangeEvent.Check_ItemInCollection("Dashboard",
                                                 expectedResult=True)

        # Change Meeting to stop being in mine
        sidebar.onToggleMineEvent(
            QAUITestAppLib.App_ns.SidebarToggleMineItem.event)

        afterChangeEvent = QAUITestAppLib.UITestItem("Event", self.logger)
        afterChangeEvent.AddCollection(uw("Meeting"))

        # both events should be in Meeting and not in All
        beforeChangeEvent.Check_ItemInCollection(uw("Meeting"),
                                                 expectedResult=True)
        beforeChangeEvent.Check_ItemInCollection("Dashboard",
                                                 expectedResult=False)

        afterChangeEvent.Check_ItemInCollection(uw("Meeting"),
                                                expectedResult=True)
        afterChangeEvent.Check_ItemInCollection("Dashboard",
                                                expectedResult=False)
Example #16
0
    def startTest(self):

        # creation
        task = QAUITestAppLib.UITestItem("Task", self.logger)
        
        # action
        task.SetAttr(displayName=uw("Task of sending birthday invites"), body=uw("Send birthday invitations"))
     
        # verification
        task.Check_DetailView({"displayName":uw("Task of sending birthday invites"),"body":uw("Send birthday invitations")})
Example #17
0
def GenerateContactName(view):
    name = pim.ContactName(itsView=view)
    name.firstName = random.choice(FIRSTNAMES)
    name.lastName = random.choice(LASTNAMES)

    if TEST_I18N:
        name.firstName = uw(name.firstName)
        name.lastName = uw(name.lastName)

    return name
Example #18
0
 def testAnnotateKind(self):
     kind_kind = schema.itemFor(schema.Kind, self.rv)
     CoreAnnotation(kind_kind).extraInfo = uw("Foo")
     self.assertEqual(CoreAnnotation(kind_kind).extraInfo, uw("Foo"))
     parcel = schema.parcel_for_module(__name__, self.rv)
     CoreAnnotation(kind_kind).otherItem = parcel
     self.assertEqual(
         list(getattr(parcel, __name__+".CoreAnnotation.otherItem.inverse")),
         [kind_kind]
     )
Example #19
0
def GenerateContactName(view):
    name = pim.ContactName(itsView=view)
    name.firstName = random.choice(FIRSTNAMES)
    name.lastName = random.choice(LASTNAMES)

    if TEST_I18N:
        name.firstName = uw(name.firstName)
        name.lastName = uw(name.lastName)

    return name
Example #20
0
    def startTest(self):
        
        appView = self.app_ns.itsView

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

        #create an event to export
        self.logger.startAction('Create event to export')
        event = QAUITestAppLib.UITestItem("Event", self.logger)
        event_UUID = event.item.itsUUID
        #write some stuff in the event to make it unique
        event.SetAttr(displayName=uw("Original Event"), startDate="01/01/2001", startTime="12:00 AM", body=uw("This is the original event"))
        self.logger.addComment("Created Event to Export")
    
        #export the event
        path = os.path.join(Globals.chandlerDirectory,"tools/cats/DataFiles")
        filename = 'tempOverwriteTest.ics'
        fullpath = os.path.join(path, filename)
        if os.path.exists(fullpath):
            os.remove(fullpath)
        #Upcast path to unicode since Sharing requires a unicode path
        fullpath = unicode(fullpath, sys.getfilesystemencoding())

        collection = pim.ListCollection(itsView=appView)
        # exporting all Events is VERY expensive, it doesn't seem like a good
        # way to test if events can be exported successfully.  Instead, just
        # export one event.
        #for tmpEvent in Calendar.EventStamp.getCollection(appView):
            #collection.add(tmpEvent)
        collection.add(event.item)
        sharing.exportFile(appView, fullpath, collection)
        application = wx.GetApp()
        application.Yield(True)
        self.logger.addComment("Exported event")
        
        #change the event after exporting
        event.SetAttr(displayName=uw("Changed Event"),  body=uw("This event has been changed"))
        self.logger.addComment("event changed after export")
    
        #import the original event
        sharing.importFile(appView, fullpath)
        application.Yield(True)
        self.logger.addComment("Imported exported event")
    
        #check if changed attributes have reverted to original values
            #find imported event by UUID
        self.logger.startAction("Verify event overwritten")
        found = self.app_ns.view.findUUID(event_UUID)
        if found.body == uw('This is the original event') and \
                     found.displayName == uw('Original Event'):
            self.logger.endAction(True, "Event overwriten")
        else:
            self.logger.endAction(False, 'Event not overwriten')
Example #21
0
    def testContentItem(self):

        self.loadParcel("osaf.pim")
        view = self.view

        # Check that the globals got created by the parcel
        self.assert_(items.ContentItem.getDefaultParent(view))
        self.assert_(items.ContentItem.getKind(view))
        self.assert_(items.Project.getKind(view))
        self.assert_(items.Group.getKind(view))

        # Construct a sample item
        view = self.view
        genericContentItem = items.ContentItem("genericContentItem",
                                               itsView=view)
        genericProject = items.Project("genericProject", itsView=view)
        genericGroup = items.Group("genericGroup", itsView=view)

        # Check that each item was created
        self.assert_(genericContentItem)
        self.assert_(genericProject)
        self.assert_(genericGroup)

        # Check each item's parent, make sure it has a path
        contentItemParent = items.ContentItem.getDefaultParent(view)
        self.assertEqual(genericContentItem.itsParent, contentItemParent)
        self.assertEqual(genericProject.itsParent, contentItemParent)
        self.assertEqual(genericGroup.itsParent, contentItemParent)

        self.assertEqual(repr(genericContentItem.itsPath),
                         '//userdata/genericContentItem')
        self.assertEqual(repr(genericProject.itsPath),
                         '//userdata/genericProject')
        self.assertEqual(repr(genericGroup.itsPath), '//userdata/genericGroup')

        # Set and test simple attributes
        genericContentItem.displayName = uw("Test Content Item")
        genericContentItem.context = uw("work")
        genericContentItem.body = uw("Notes appear in the body")

        self.assertEqual(genericContentItem.displayName,
                         uw("Test Content Item"))
        self.assertEqual(genericContentItem.context, uw("work"))
        self.assertEqual(genericContentItem.body,
                         uw("Notes appear in the body"))

        # Test Calculated basedOn
        self.assertEqual(genericContentItem.getBasedAttributes('body'),
                         ('body', ))

        genericProject.name = uw("Test Project")
        genericGroup.name = uw("Test Group")

        self.assertEqual(genericProject.name, uw("Test Project"))
        self.assertEqual(genericGroup.name, uw("Test Group"))
Example #22
0
    def testContentItem(self):

        self.loadParcel("osaf.pim")
        view = self.view

        # Check that the globals got created by the parcel
        self.assert_(items.ContentItem.getDefaultParent(view))
        self.assert_(items.ContentItem.getKind(view))
        self.assert_(items.Project.getKind(view))
        self.assert_(items.Group.getKind(view))

        # Construct a sample item
        view = self.view
        genericContentItem = items.ContentItem("genericContentItem",
                                                      itsView=view)
        genericProject = items.Project("genericProject", itsView=view)
        genericGroup = items.Group("genericGroup", itsView=view)

        # Check that each item was created
        self.assert_(genericContentItem)
        self.assert_(genericProject)
        self.assert_(genericGroup)

        # Check each item's parent, make sure it has a path
        contentItemParent = items.ContentItem.getDefaultParent(view)
        self.assertEqual(genericContentItem.itsParent, contentItemParent)
        self.assertEqual(genericProject.itsParent, contentItemParent)
        self.assertEqual(genericGroup.itsParent, contentItemParent)

        self.assertEqual(repr(genericContentItem.itsPath),
                         '//userdata/genericContentItem')
        self.assertEqual(repr(genericProject.itsPath),
                         '//userdata/genericProject')
        self.assertEqual(repr(genericGroup.itsPath),
                         '//userdata/genericGroup')

        # Set and test simple attributes
        genericContentItem.displayName = uw("Test Content Item")
        genericContentItem.context = uw("work")
        genericContentItem.body = uw("Notes appear in the body")

        self.assertEqual(genericContentItem.displayName, uw("Test Content Item"))
        self.assertEqual(genericContentItem.context, uw("work"))
        self.assertEqual(genericContentItem.body, uw("Notes appear in the body"))

        # Test Calculated basedOn
        self.assertEqual(genericContentItem.getBasedAttributes('body'), ('body',))

        genericProject.name = uw("Test Project")
        genericGroup.name = uw("Test Group")


        self.assertEqual(genericProject.name, uw("Test Project"))
        self.assertEqual(genericGroup.name, uw("Test Group"))
Example #23
0
 def testAnnotateKind(self):
     kind_kind = schema.itemFor(schema.Kind, self.rv)
     CoreAnnotation(kind_kind).extraInfo = uw("Foo")
     self.assertEqual(CoreAnnotation(kind_kind).extraInfo, uw("Foo"))
     parcel = schema.parcel_for_module(__name__, self.rv)
     CoreAnnotation(kind_kind).otherItem = parcel
     self.assertEqual(
         list(
             getattr(parcel,
                     __name__ + ".CoreAnnotation.otherItem.inverse")),
         [kind_kind])
Example #24
0
    def startTest(self):

        START_DATE = 0
        START_TIME = 1
        END_DATE   = 2
        END_TIME   = 3
        TIMEZONE   = 4
        
            # tests that need to be added:
            #     week to week transistions
            #     non-pacific time zones
            #     other locales
        
        dateValues = { 'us': [  # year end transistion
                              ('12/31/04', '11:30 PM', '1/1/05',   '12:30 AM', 'America/Chicago'),
                                # leap year (feb has 29 days)
                              ('2/28/04',  '11:30 PM', '2/29/04',  '12:30 AM', 'America/Chicago'),
                                # leap year (feb has 29 days)
                              ('2/29/04',  '11:30 PM', '3/1/04',   '12:30 AM', 'America/Chicago'),
                                # Daylight savings time start
                              ('4/2/06',   '1:00 AM',  '4/2/06',   '3:00 AM',  'America/Chicago'),
                                # Daylight savings time end
                              ('10/29/06', '2:00 AM',  '10/29/06', '1:00 AM',  'America/Chicago'),
                             ],
                     }
    
        # make user collection, since only user
        # collections can be displayed as a calendar
        col = QAUITestAppLib.UITestItem("Collection", self.logger)

        # creation
        event = QAUITestAppLib.UITestItem("Event", self.logger)
    
        for locale in dateValues:
            testItems = dateValues[locale]
    
            for test in testItems:
                s = uw('%s %s :: %s %s :: %s' % test)
    
                event.SetAttr(displayName=uw("Test"),
                              startDate=test[START_DATE],
                              startTime=test[START_TIME],
                              body=s,
                              timeZone=test[TIMEZONE]
                             )
    
                event.Check_DetailView({"displayName": uw("Test"),
                                        "startDate":   test[START_DATE],
                                        "endDate":     test[END_DATE],
                                        "startTime":   test[START_TIME],
                                        "endTime":     test[END_TIME],
                                        "body":        s,
                                       })
Example #25
0
def GenerateMailMessage(view, tzinfo=None):
    global M_FROM
    message  = Mail.MailMessage(itsView=view)
    body     = M_TEXT

    outbound = random.randint(0, 1)
    type     = random.randint(1, 8)
    numTo    = random.randint(1, 3)

    if M_FROM is None:
        M_FROM = GenerateCalendarParticipant(view)

    message.fromAddress = M_FROM

    for num in range(numTo):
        message.toAddress.append(GenerateCalendarParticipant(view))

    message.subject  = random.choice(TITLES)

    if TEST_I18N:
        message.subject = uw(message.subject)

    message.dateSent = datetime.now(tzinfo)

    if outbound:
        message.outgoingMessage()
        message.itsItem.changeEditState(Modification.sent, who=M_FROM)

    else:
        message.incomingMessage()

    if type == EVENT:
        Calendar.EventStamp(message).add()
        body += M_EVENT

    if type == TASK:
        pim.TaskStamp(message).add()
        body += M_TASK

    if type == BOTH:
        Calendar.EventStamp(message).add()
        pim.TaskStamp(message).add()
        body += M_BOTH

    if TEST_I18N:
        body = uw(body)

    message.body = body
    message.itsItem.setTriageStatus(randomEnum(pim.TriageEnum))

    return message.itsItem
Example #26
0
def GenerateMailMessage(view, tzinfo=None):
    global M_FROM
    message = Mail.MailMessage(itsView=view)
    body = M_TEXT

    outbound = random.randint(0, 1)
    type = random.randint(1, 8)
    numTo = random.randint(1, 3)

    if M_FROM is None:
        M_FROM = GenerateCalendarParticipant(view)

    message.fromAddress = M_FROM

    for num in range(numTo):
        message.toAddress.append(GenerateCalendarParticipant(view))

    message.subject = random.choice(TITLES)

    if TEST_I18N:
        message.subject = uw(message.subject)

    message.dateSent = datetime.now(tzinfo)

    if outbound:
        message.outgoingMessage()
        message.itsItem.changeEditState(Modification.sent, who=M_FROM)

    else:
        message.incomingMessage()

    if type == EVENT:
        Calendar.EventStamp(message).add()
        body += M_EVENT

    if type == TASK:
        pim.TaskStamp(message).add()
        body += M_TASK

    if type == BOTH:
        Calendar.EventStamp(message).add()
        pim.TaskStamp(message).add()
        body += M_BOTH

    if TEST_I18N:
        body = uw(body)

    message.body = body
    message.itsItem.setTriageStatus(randomEnum(pim.TriageEnum))

    return message.itsItem
Example #27
0
def GenerateCalendarEvent(view, days=30, tzinfo=None):
    if tzinfo is None:
        tzinfo = view.tzinfo.floating
    event = Calendar.CalendarEvent(itsView=view)
    event.summary = random.choice(HEADLINES)

    if TEST_I18N:
        event.summary = uw(event.summary)

    # Choose random days, hours
    startDelta = timedelta(days=random.randint(0, days),
                           hours=random.randint(0, 24))

    now = datetime.now(tzinfo)
    closeToNow = datetime(now.year,
                          now.month,
                          now.day,
                          now.hour,
                          int(now.minute / 30) * 30,
                          tzinfo=now.tzinfo)
    event.startTime = closeToNow + startDelta

    # Events are anyTime by default. Give a 5% chance of allDay instead,
    # or 90% of a normal event.
    r = random.randint(0, 100)
    if r < 95:  # 5% chance that we'll leave anyTime on
        event.anyTime = False
    if r < 5:  # 5% chance of allDay
        event.allDay = True

    # Choose random minutes
    event.duration = timedelta(minutes=random.choice(DURATIONS))

    # Maybe a nice reminder?
    reminderInterval = random.choice(REMINDERS)
    if reminderInterval is not None:
        event.userReminderInterval = timedelta(minutes=-reminderInterval)

    # Add a location to 2/3 of the events
    if random.randrange(3) > 0:
        if TEST_I18N:
            event.location = Calendar.Location.getLocation(
                view, uw(random.choice(LOCATIONS)))
        else:
            event.location = Calendar.Location.getLocation(
                view, random.choice(LOCATIONS))

    event.itsItem.importance = random.choice(pim.ImportanceEnum.values)
    event.itsItem.setTriageStatus(randomEnum(pim.TriageEnum))
    return event.itsItem
Example #28
0
 def startTest(self):
         
     # action
     col = QAUITestAppLib.UITestItem("Collection", self.logger)
     # verification
     col.Check_CollectionExistence("Untitled")
     
     # action
     col.SetDisplayName(uw("Meeting"))
     # verification
     col.Check_CollectionExistence(uw("Meeting"))
     
     # action
     note = QAUITestAppLib.UITestItem("Note", self.logger)
     note.AddCollection(uw("Meeting"))
     # verification
     note.Check_ItemInCollection(uw("Meeting"))
     
     # Bug 5803, make sure items in collections that change to not mine
     # are really not in the All collection, and similarly that events
     # created after the collection becomes not mine are truly not mine
 
     sidebar = QAUITestAppLib.App_ns.sidebar
 
     # select the Meeting collection
     scripting.User.emulate_sidebarClick(sidebar, uw('Meeting'))
 
     # Switch to the Calendar View
     QAUITestAppLib.App_ns.appbar.press("ApplicationBarEventButton")
     
     # ... idle() so the app can handle changes
     QAUITestAppLib.scripting.User.idle()
 
     beforeChangeEvent = QAUITestAppLib.UITestItem("Event", self.logger)
     beforeChangeEvent.AddCollection(uw("Meeting"))
     beforeChangeEvent.Check_ItemInCollection(uw("Meeting"), expectedResult=True)
     beforeChangeEvent.Check_ItemInCollection("Dashboard", expectedResult=True)
     
     # Change Meeting to stop being in mine
     sidebar.onToggleMineEvent(QAUITestAppLib.App_ns.SidebarToggleMineItem.event)
     
     afterChangeEvent = QAUITestAppLib.UITestItem("Event", self.logger)
     afterChangeEvent.AddCollection(uw("Meeting"))
 
     # both events should be in Meeting and not in All
     beforeChangeEvent.Check_ItemInCollection(uw("Meeting"), expectedResult=True)
     beforeChangeEvent.Check_ItemInCollection("Dashboard", expectedResult=False)
 
     afterChangeEvent.Check_ItemInCollection(uw("Meeting"), expectedResult=True)
     afterChangeEvent.Check_ItemInCollection("Dashboard", expectedResult=False)
Example #29
0
    def testICSSerializer(self):
        """Tests serialization of items to icalendar streams."""
        event = Calendar.CalendarEvent(itsView=self.view)
        event.anyTime = False
        event.summary = uw("test")
        event.startTime = datetime.datetime(2010,
                                            1,
                                            1,
                                            10,
                                            tzinfo=self.view.tzinfo.default)
        event.endTime = datetime.datetime(2010,
                                          1,
                                          1,
                                          11,
                                          tzinfo=self.view.tzinfo.default)

        cal = getVObjectData(self.view, [event.itsItem])

        self.failUnlessEqual(
            cal.vevent.summary.value, uw("test"),
            u"summary not set properly, summary is %s" %
            cal.vevent.summary.value)

        start = event.startTime
        self.assert_(
            cal.vevent.dtstart.value == start,
            "dtstart not set properly, dtstart is %s" %
            cal.vevent.summary.value)

        event = Calendar.CalendarEvent(itsView=self.view)
        event.summary = uw("test2")
        event.startTime = datetime.datetime(2010,
                                            1,
                                            1,
                                            tzinfo=self.view.tzinfo.floating)
        event.allDay = True
        event.duration = datetime.timedelta(1)
        self.assertEqual(event.effectiveEndTime - event.effectiveStartTime,
                         datetime.timedelta(2))
        cal = getVObjectData(self.view, [event.itsItem])

        self.assert_(
            cal.vevent.dtstart.value == datetime.date(2010, 1, 1),
            u"dtstart for allDay event not set properly, dtstart is %s" %
            cal.vevent.summary.value)

        # test bug 9137, multi-day all-day events with
        # duration modulo 1 day == 0 are serialized as 1 day instead of 2
        self.assertEqual(cal.vevent.duration.value, datetime.timedelta(2))
def GenerateTask(view, args):
    """ Generate one Task item """
    task = Task(itsView=view)

    # displayName
    if args[0]=='*': # semi-random data
        task.displayName = random.choice(TITLES)


    elif not args[0]=='':
        task.displayName = u"%s" %args[0]
    else:
        task.displayName = u'untitled'

    if TEST_I18N:
        task.displayName = uw(task.displayName)


    #collection
    if args[1]=='*': # semi-random data
        collectionsDict.values()[random.randint(0,len(collectionsDict)-1)].add(task)
    elif not args[1]=='':
        collectionNames = string.split(args[1], ';') 
        for name in collectionNames:
            if collectionsDict.has_key(name):
                collectionsDict[name].add(task)
            else:
                GenerateCollection(view, [name])
                collectionsDict[name].add(task)

    return task
Example #31
0
def addTaskStamp(item):
    ts = TaskStamp(item)
    ts.add()

    ts.summary = uw("Test Task Summary")
    ts.itsItem.setTriageStatus(randomEnum(pim.TriageEnum))
    return ts
 def startTest(self):
         
     # switch to the all view
     testView = QAUITestAppLib.UITestView(self.logger)
 
     # We need to look at the all view
     testView.SwitchToAllView()
 
     # can't do the next two steps because modal dialogs don't work
     # with emulate_typing
 #    app_ns().root.NewFlickrCollectionByTag()
 #    User.emulate_typing("oscon2005")
 
     # this is what we do instead
     view = self.app_ns.itsView
     # get a collection of photos from the oscon2005 tag
     fc = flickr.PhotoCollection(itsView = view)
     fc.tag = flickr.Tag.getTag(view, "oscon2005")
     fc.displayName = uw("oscon2005")
 
     self.logger.startAction('Get a flickr collection by tag')
     try:
         fc.fillCollectionFromFlickr(view, 10,
                                     '831f4f96fa5bf41fb9ed1317174ebbbe')
     except socket.timeout:
         self.logger.endAction(True, "Flickr timed out; skipping test")
     except IOError, e:
         self.logger.endAction(True, "IOError (%s); skipping test" % str(e))
    def testTask(self):
        """ Simple test for creating instances of tasks """
        def _verifyTask(taskItem):
            self.failUnless(has_stamp(taskItem, TaskStamp))
            self.failUnlessEqual(taskItem.displayName, uw("test headline"))
            self.failUnlessEqual(taskItem.importance, 'important')

        self.loadParcel("osaf.pim.tasks")

        # Check that the globals got created by the parcel
        view = self.view
        taskPath = Path('//parcels/osaf/pim/tasks')
        self.failIfEqual(schema.itemFor(TaskStamp, view), None)
        self.failIfEqual(view.find(Path(taskPath, 'TaskStamp')), None)

        self.failUnlessEqual(schema.itemFor(TaskStamp, view),
                             view.find(Path(taskPath, 'TaskStamp')))

        # Construct A Sample Item
        task = Task("TestTask", itsView=view)
        task.itsItem.displayName = uw("test headline")
        task.itsItem.importance = "important"

        self._reopenRepository()
        view = self.view

        contentItemParent = view.findPath("//userdata")

        taskItem2 = contentItemParent.getItemChild("TestTask")
        _verifyTask(taskItem2)
Example #34
0
 def _createEvent(self, startTime):
     event = Calendar.CalendarEvent(None, itsView=self.view)
     event.startTime = startTime
     event.endTime = event.startTime + timedelta(hours=1)
     event.anyTime = False
     event.summary = uw("Sample event")
     return event    
Example #35
0
def addTaskStamp(item):
    ts = TaskStamp(item)
    ts.add()

    ts.summary = uw("Test Task Summary")
    ts.itsItem.setTriageStatus(randomEnum(pim.TriageEnum))
    return ts
def GenerateNote(view, args):
    """ Generate one Note item """
    note = pim.Note(itsView=view)
    #displayName
    if args[0]=='*': # semi-random data

        note.displayName = random.choice(TITLES)

    elif not args[0]=='':
         note.displayName = u"%s" %args[0]
    else:
        note.displayName = u'untitled' #default value which does not require localization since this is a util

    if TEST_I18N:
        note.displayName = uw(note.displayName)

    #createdOn
    note.createdOn = ReturnCompleteDatetime(args[2],args[3])
    #collection
    if args[1]=='*': # semi-random data
        collectionsDict.values()[random.randint(0,len(collectionsDict)-1)].add(note)
    elif not args[1]=='':
        collectionNames = string.split(args[1], ';') 
        for name in collectionNames:
            if collectionsDict.has_key(name):
                collectionsDict[name].add(note)
            else:
                GenerateCollection(view, [name])
                collectionsDict[name].add(note)

    return note
    def startTest(self):

        # creation
        task = QAUITestAppLib.UITestItem("Task", self.logger)

        # action
        task.SetAttr(displayName=uw("Task of sending birthday invites"),
                     body=uw("Send birthday invitations"))

        # verification
        task.Check_DetailView({
            "displayName":
            uw("Task of sending birthday invites"),
            "body":
            uw("Send birthday invitations")
        })
Example #38
0
    def testTask(self):
        """ Simple test for creating instances of tasks """

        def _verifyTask(taskItem):
            self.failUnless(has_stamp(taskItem, TaskStamp))
            self.failUnlessEqual(taskItem.displayName, uw("test headline"))
            self.failUnlessEqual(taskItem.importance, 'important')

        self.loadParcel("osaf.pim.tasks")

        # Check that the globals got created by the parcel
        view = self.view
        taskPath = Path('//parcels/osaf/pim/tasks')
        self.failIfEqual(schema.itemFor(TaskStamp, view), None)
        self.failIfEqual(view.find(Path(taskPath, 'TaskStamp')), None)

        self.failUnlessEqual(schema.itemFor(TaskStamp, view),
                         view.find(Path(taskPath, 'TaskStamp')))

        # Construct A Sample Item
        task = Task("TestTask", itsView=view)
        task.itsItem.displayName = uw("test headline")
        task.itsItem.importance = "important"

        self._reopenRepository()
        view = self.view

        contentItemParent = view.findPath("//userdata")

        taskItem2 = contentItemParent.getItemChild("TestTask")
        _verifyTask(taskItem2)
Example #39
0
def addMaiStamp(item):
    ms = MailStamp(item)
    ms.add()

    ms.subject = uw("Test Mail")
    ms.body = uw("Test ") * 60

    toAddr = EmailAddress.getEmailAddress(view, "*****@*****.**")
    ms.toAddress.append(toAddr)

    ms.fromAddress = EmailAddress.getEmailAddress(view, "*****@*****.**")
    ms.ccAddress.append(ms.fromAddress)

    org = EmailAddress.getEmailAddress(view, "The Management")
    ms.originators.append(org)

    return ms
Example #40
0
    def testExportRecurrence(self):
        eastern = self.view.tzinfo.getInstance("America/New_York")
        start = datetime.datetime(2005, 2, 1, tzinfo=eastern)
        vevent = vobject.icalendar.RecurringComponent(name='VEVENT')
        vevent.behavior = vobject.icalendar.VEvent

        vevent.add('dtstart').value = start

        ruleSetItem = self._makeRecurrenceRuleSet()
        vevent.rruleset = ruleSetItem.createDateUtilFromRule(start)

        self.assertEqual(vevent.rrule.value, 'FREQ=DAILY')

        event = Calendar.CalendarEvent(itsView=self.view)
        event.anyTime = False
        event.summary = uw("blah")
        event.startTime = start
        event.endTime = datetime.datetime(2005, 2, 1, 1, tzinfo=eastern)

        event.rruleset = self._makeRecurrenceRuleSet(
            datetime.datetime(2005, 3, 1, tzinfo=eastern),
            freq='weekly',
            byweekday=[
                WeekdayAndPositionStruct(i, 0) for i in "tuesday", "thursday"
            ])

        vcalendar = getVObjectData(self.view, [event.itsItem])

        self.assertEqual(vcalendar.vevent.dtstart.serialize(),
                         'DTSTART;TZID=America/New_York:20050201T000000\r\n')
        vcalendar.vevent = vcalendar.vevent.transformFromNative()
        self.assertEqual(
            vcalendar.vevent.rrule.serialize(),
            'RRULE:FREQ=WEEKLY;BYDAY=TU,TH;UNTIL=20050302T045900Z\r\n')

        # move the second occurrence one day later
        nextEvent = event.getFirstOccurrence().getNextOccurrence()
        nextEvent.changeThis(
            pim.EventStamp.startTime.name,
            datetime.datetime(2005, 2, 9, tzinfo=self.view.tzinfo.floating))

        nextEvent.getNextOccurrence().deleteThis()

        vcalendar = getVObjectData(self.view, [event.itsItem, nextEvent])
        for ev in vcalendar.vevent_list:
            if hasattr(ev, 'recurrence_id'):
                modified = ev
            else:
                master = ev
        self.assertEqual(modified.dtstart.serialize(),
                         'DTSTART:20050209T000000\r\n')
        self.assertEqual(
            modified.recurrence_id.serialize(),
            'RECURRENCE-ID;TZID=America/New_York:20050203T000000\r\n')
        self.assertEqual(master.exdate.serialize(),
                         'EXDATE;TZID=America/New_York:20050210T000000\r\n')
        vcalendar.behavior.generateImplicitParameters(vcalendar)
        self.assertEqual(vcalendar.vtimezone.tzid.value, "America/New_York")
Example #41
0
def addMaiStamp(item):
    ms = MailStamp(item)
    ms.add()

    ms.subject = uw("Test Mail")
    ms.body = uw("Test ") * 60

    toAddr = EmailAddress.getEmailAddress(view, "*****@*****.**")
    ms.toAddress.append(toAddr)

    ms.fromAddress = EmailAddress.getEmailAddress(view,
                                                  "*****@*****.**")
    ms.ccAddress.append(ms.fromAddress)

    org = EmailAddress.getEmailAddress(view, "The Management")
    ms.originators.append(org)

    return ms
Example #42
0
def GenerateCalendarEvent(view, days=30, tzinfo=None):
    if tzinfo is None:
        tzinfo = view.tzinfo.floating
    event = Calendar.CalendarEvent(itsView=view)
    event.summary = random.choice(HEADLINES)

    if TEST_I18N:
        event.summary = uw(event.summary)

    # Choose random days, hours
    startDelta = timedelta(days=random.randint(0, days),
                           hours=random.randint(0, 24))

    now = datetime.now(tzinfo)
    closeToNow = datetime(now.year, now.month, now.day, now.hour,
                          int(now.minute/30) * 30, tzinfo=now.tzinfo)
    event.startTime = closeToNow + startDelta

    # Events are anyTime by default. Give a 5% chance of allDay instead,
    # or 90% of a normal event.
    r = random.randint(0,100)
    if r < 95: # 5% chance that we'll leave anyTime on
        event.anyTime = False
    if r < 5: # 5% chance of allDay
        event.allDay = True

    # Choose random minutes
    event.duration = timedelta(minutes=random.choice(DURATIONS))
    
    # Maybe a nice reminder?
    reminderInterval = random.choice(REMINDERS)
    if reminderInterval is not None:
        event.userReminderInterval = timedelta(minutes=-reminderInterval)
        
    # Add a location to 2/3 of the events
    if random.randrange(3) > 0:
        if TEST_I18N:
            event.location = Calendar.Location.getLocation(view, uw(random.choice(LOCATIONS)))
        else:
            event.location = Calendar.Location.getLocation(view, random.choice(LOCATIONS))

    event.itsItem.importance = random.choice(pim.ImportanceEnum.values)
    event.itsItem.setTriageStatus(randomEnum(pim.TriageEnum))
    return event.itsItem
Example #43
0
def addEventStamp(item, recur=False):
    es = EventStamp(item)
    es.add()
    es.summary = uw("Test Event Summary")

    tzinfo = item.itsView.tzinfo.floating

    # Choose random days, hours
    startDelta = timedelta(days=random.randint(0, 30),
                           hours=random.randint(0, 24))

    now = datetime.now(tzinfo)

    closeToNow = datetime(now.year,
                          now.month,
                          now.day,
                          now.hour,
                          int(now.minute / 30) * 30,
                          tzinfo=now.tzinfo)

    es.startTime = closeToNow + startDelta
    es.anyTime = True

    # Choose random minutes
    es.duration = timedelta(minutes=60)

    es.location = Calendar.Location.getLocation(view, uw("My House"))

    es.itsItem.importance = random.choice(pim.ImportanceEnum.values)

    es.itsItem.setTriageStatus(randomEnum(pim.TriageEnum))

    if recur:
        rule = RecurrenceRule(itsView=view)
        rule.freq = 'daily'
        rule.until = datetime(2008, 9, 14, 19, tzinfo=view.tzinfo.default)
        rule.untilIsDate = False

        ruleSet = RecurrenceRuleSet(itsView=view)
        ruleSet.addRule(rule)

        es.rruleset = ruleSet

    return es
    def setUp(self):
        u = uw("profileDir_")
        self.path = os.path.join(os.path.dirname(__file__), u.encode('utf8'))

        try:
            os.makedirs(self.path)
        except OSError:
            pass

        self._removePool()
Example #45
0
    def __populateAccount(self, account):

        #XXX: i18n usernames and passwords can be non-ascii.
        # Need to investigate how best to deal with this as
        # there is no standard. It is server implementation dependent.
        account.username = uw("test")
        account.password = password.Password(itsView=account.itsView,
                                             itsParent=account)
        waitForDeferred(account.password.encryptPassword(uw("test")))
        account.host = uw("test")

        if type(account) == Mail.AccountBase:
            account.port = 1
            account.connectionSecurity = "NONE"

        if type(account) == Mail.SMTPAccount:
            account.fullName = uw("test")
            account.replyToAddress = Mail.EmailAddress(itsView=account.itsView)
            account.replyToAddress.emailAddress = "*****@*****.**"
Example #46
0
    def __populateAccount(self, account):

        #XXX: i18n usernames and passwords can be non-ascii.
        # Need to investigate how best to deal with this as 
        # there is no standard. It is server implementation dependent.
        account.username = uw("test")
        account.password = password.Password(itsView=account.itsView,
                                             itsParent=account)
        waitForDeferred(account.password.encryptPassword(uw("test")))
        account.host = uw("test")

        if type(account) == Mail.AccountBase:
            account.port = 1
            account.connectionSecurity = "NONE"

        if type(account) == Mail.SMTPAccount:
            account.fullName = uw("test")
            account.replyToAddress = Mail.EmailAddress(itsView=account.itsView)
            account.replyToAddress.emailAddress = "*****@*****.**"
Example #47
0
    def testExportRecurrence(self):
        eastern = self.view.tzinfo.getInstance("America/New_York")
        start = datetime.datetime(2005,2,1, tzinfo = eastern)
        vevent = vobject.icalendar.RecurringComponent(name='VEVENT')
        vevent.behavior = vobject.icalendar.VEvent

        vevent.add('dtstart').value = start

        ruleSetItem = self._makeRecurrenceRuleSet()
        vevent.rruleset = ruleSetItem.createDateUtilFromRule(start)
        
        self.assertEqual(vevent.rrule.value, 'FREQ=DAILY')

        event = Calendar.CalendarEvent(itsView = self.view)
        event.anyTime = False
        event.summary = uw("blah")
        event.startTime = start
        event.endTime = datetime.datetime(2005,2,1,1, tzinfo = eastern)

        event.rruleset = self._makeRecurrenceRuleSet(
            datetime.datetime(2005,3,1, tzinfo = eastern),
            freq='weekly',
            byweekday=[WeekdayAndPositionStruct(i, 0) for i in "tuesday", "thursday"]
        )
        
        vcalendar = getVObjectData(self.view, [event.itsItem])

        self.assertEqual(vcalendar.vevent.dtstart.serialize(),
                         'DTSTART;TZID=America/New_York:20050201T000000\r\n')
        vcalendar.vevent = vcalendar.vevent.transformFromNative()
        self.assertEqual(vcalendar.vevent.rrule.serialize(),
                         'RRULE:FREQ=WEEKLY;BYDAY=TU,TH;UNTIL=20050302T045900Z\r\n')

        # move the second occurrence one day later
        nextEvent = event.getFirstOccurrence().getNextOccurrence()
        nextEvent.changeThis(pim.EventStamp.startTime.name,
                             datetime.datetime(2005,2,9,
                                               tzinfo=self.view.tzinfo.floating))

        nextEvent.getNextOccurrence().deleteThis()

        vcalendar = getVObjectData(self.view, [event.itsItem, nextEvent])
        for ev in vcalendar.vevent_list:
            if hasattr(ev, 'recurrence_id'):
                modified = ev
            else:
                master = ev
        self.assertEqual(modified.dtstart.serialize(),
                         'DTSTART:20050209T000000\r\n')
        self.assertEqual(modified.recurrence_id.serialize(),
                         'RECURRENCE-ID;TZID=America/New_York:20050203T000000\r\n')
        self.assertEqual(master.exdate.serialize(),
                         'EXDATE;TZID=America/New_York:20050210T000000\r\n')
        vcalendar.behavior.generateImplicitParameters(vcalendar)
        self.assertEqual(vcalendar.vtimezone.tzid.value, "America/New_York")
 def startTest(self):
     
     #make sure we start in the calendar view
     QAUITestAppLib.UITestItem("Collection", self.logger)
     QAUITestAppLib.UITestView(self.logger).SwitchToCalView()
     
     # creation
     col = QAUITestAppLib.UITestItem("Collection", self.logger)
     col.SetDisplayName(uw("ToBeDeleted"))
 
     # action
     sb = self.app_ns.sidebar
     # move focus from collection name text to collection. This
     # requires 2 clicks
     scripting.User.emulate_sidebarClick(sb, uw("ToBeDeleted"))
     scripting.User.emulate_sidebarClick(sb, uw("ToBeDeleted"))
     col.DeleteCollection()
 
     # verification
     col.Check_CollectionExistence(expectedResult=False)
Example #49
0
def GenerateTask(view, tzinfo=None):
    """ Generate one Task item """
    task = pim.Task(itsView=view)
    delta = timedelta(days=random.randint(0, 5), hours=random.randint(0, 24))
    task.summary = random.choice(TITLES)

    if TEST_I18N:
        task.summary = uw(task.summary)

    task.itsItem.setTriageStatus(randomEnum(pim.TriageEnum))
    return task.itsItem
    def startTest(self):

        #make sure we start in the calendar view
        QAUITestAppLib.UITestItem("Collection", self.logger)
        QAUITestAppLib.UITestView(self.logger).SwitchToCalView()

        # creation
        col = QAUITestAppLib.UITestItem("Collection", self.logger)
        col.SetDisplayName(uw("ToBeDeleted"))

        # action
        sb = self.app_ns.sidebar
        # move focus from collection name text to collection. This
        # requires 2 clicks
        scripting.User.emulate_sidebarClick(sb, uw("ToBeDeleted"))
        scripting.User.emulate_sidebarClick(sb, uw("ToBeDeleted"))
        col.DeleteCollection()

        # verification
        col.Check_CollectionExistence(expectedResult=False)
Example #51
0
    def setUp(self):
        u = uw("profileDir_")
        self.path = os.path.join(os.path.dirname(__file__),
                                 u.encode('utf8'))

        try:
            os.makedirs(self.path)
        except OSError:
            pass

        self._removePool()
Example #52
0
def GenerateTask(view, tzinfo=None):
    """ Generate one Task item """
    task = pim.Task(itsView=view)
    delta = timedelta(days=random.randint(0, 5),
                      hours=random.randint(0, 24))
    task.summary = random.choice(TITLES)

    if TEST_I18N:
        task.summary = uw(task.summary)

    task.itsItem.setTriageStatus(randomEnum(pim.TriageEnum))
    return task.itsItem
Example #53
0
def GenerateNote(view, tzinfo=None):
    """ Generate one Note item """
    note = pim.Note(itsView=view)
    note.displayName = random.choice(TITLES)

    if TEST_I18N:
        note.displayName = uw(note.displayName)

    delta = timedelta(days=random.randint(0, 5), hours=random.randint(0, 24))
    note.createdOn = datetime.now(tzinfo) + delta
    note.setTriageStatus(randomEnum(pim.TriageEnum))
    return note
Example #54
0
def addEventStamp(item, recur=False):
    es = EventStamp(item)
    es.add()
    es.summary = uw("Test Event Summary")

    tzinfo = view.tzinfo.floating

    # Choose random days, hours
    startDelta = timedelta(days=random.randint(0, 30),
                           hours=random.randint(0, 24))

    now = datetime.now(tzinfo)

    closeToNow = datetime(now.year, now.month, now.day, now.hour,
                          int(now.minute/30) * 30, tzinfo=now.tzinfo)

    es.startTime = closeToNow + startDelta
    es.anyTime = True

    # Choose random minutes
    es.duration = timedelta(minutes=60)

    es.location = Calendar.Location.getLocation(view, uw("My House"))

    es.itsItem.importance = random.choice(pim.ImportanceEnum.values)

    es.itsItem.setTriageStatus(randomEnum(pim.TriageEnum))

    if recur:
        rule = RecurrenceRule(itsView=view)
        rule.freq = 'daily'
        rule.until =  datetime(2008, 9, 14, 19, tzinfo=view.tzinfo.default)
        rule.untilIsDate = False

        ruleSet = RecurrenceRuleSet(itsView=view)
        ruleSet.addRule(rule)

        es.rruleset = ruleSet

    return es
Example #55
0
    def startTest(self):

        today = strftime('%m/%d/%Y', localtime())

        view = QAUITestAppLib.UITestView(self.logger)

        #Create a collection and select it
        collection = QAUITestAppLib.UITestItem("Collection", self.logger)
        collection.SetDisplayName(uw("stacked"))
        sidebar = self.app_ns.sidebar
        QAUITestAppLib.scripting.User.emulate_sidebarClick(
            sidebar, uw("stacked"))

        # Make sure we are in calendar view, need to do this AFTER creating a
        # collection, or we might be in the dashboard
        view.SwitchToCalView()

        #make sure we are on current week
        view.GoToToday()

        # creation
        for i in range(10):
            eventName = uw('Stacked Event %d' % i)
            event = QAUITestAppLib.UITestItem("Event", self.logger)

            #action
            event.SetAttr(displayName=eventName,
                          startDate=today,
                          startTime="12:00 PM",
                          body=uw("Stacked event test"))

            #verification
            event.Check_DetailView({
                "displayName": eventName,
                "startDate": today,
                "endDate": today,
                "startTime": "12:00 PM",
                "body": uw("Stacked event test")
            })
    def startTest(self):

        appView = self.app_ns.itsView

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

        #create an event to export
        self.logger.startAction('Create event to export')
        event = QAUITestAppLib.UITestItem("Event", self.logger)
        event_UUID = event.item.itsUUID
        #write some stuff in the event to make it unique
        event.SetAttr(displayName=uw("Original Event"),
                      startDate="01/01/2001",
                      startTime="12:00 AM",
                      body=uw("This is the original event"))
        self.logger.addComment("Created Event to Export")

        #export the event
        path = os.path.join(Globals.chandlerDirectory, "tools/cats/DataFiles")
        filename = 'tempOverwriteTest.ics'
        fullpath = os.path.join(path, filename)
        if os.path.exists(fullpath):
            os.remove(fullpath)
        #Upcast path to unicode since Sharing requires a unicode path
        fullpath = unicode(fullpath, sys.getfilesystemencoding())

        collection = pim.ListCollection(itsView=appView)
        # exporting all Events is VERY expensive, it doesn't seem like a good
        # way to test if events can be exported successfully.  Instead, just
        # export one event.
        #for tmpEvent in Calendar.EventStamp.getCollection(appView):
        #collection.add(tmpEvent)
        collection.add(event.item)
        sharing.exportFile(appView, fullpath, collection)
        application = wx.GetApp()
        application.Yield(True)
        self.logger.addComment("Exported event")

        #change the event after exporting
        event.SetAttr(displayName=uw("Changed Event"),
                      body=uw("This event has been changed"))
        self.logger.addComment("event changed after export")

        #import the original event
        sharing.importFile(appView, fullpath)
        application.Yield(True)
        self.logger.addComment("Imported exported event")

        #check if changed attributes have reverted to original values
        #find imported event by UUID
        self.logger.startAction("Verify event overwritten")
        found = self.app_ns.view.findUUID(event_UUID)
        if found.body == uw('This is the original event') and \
                     found.displayName == uw('Original Event'):
            self.logger.endAction(True, "Event overwriten")
        else:
            self.logger.endAction(False, 'Event not overwriten')
    def testContacts(self):
        """ Simple test for creating instances of contact related kinds """

        self.loadParcel("osaf.pim.contacts")
        def _verifyContactName(name):
            self.assertEqual(name.firstName, uw('Sylvia'))
            self.assertEqual(name.lastName, uw('Plath'))

        # Test the globals
        contactsPath = Path('//parcels/osaf/pim/contacts')
        view = self.view

        self.assertEqual(Contact.getKind(view),
                         view.find(Path(contactsPath, 'Contact')))
        self.assertEqual(ContactName.getKind(view),
                         view.find(Path(contactsPath, 'ContactName')))

        # Construct sample items
        contactItem = Contact("contactItem", itsView=view)
        contactNameItem = ContactName("contactNameItem", itsView=view)

        # Double check kinds
        self.assertEqual(contactItem.itsKind, Contact.getKind(view))
        self.assertEqual(contactNameItem.itsKind, ContactName.getKind(view))

        # Literal properties
        contactNameItem.firstName = uw("Sylvia")
        contactNameItem.lastName = uw("Plath")

        _verifyContactName(contactNameItem)

        self._reopenRepository()
        view = self.view

        contentItemParent = view.findPath("//userdata")

        contactNameItem = contentItemParent.getItemChild("contactNameItem")
        _verifyContactName(contactNameItem)