Esempio n. 1
0
def loadMailTests(view, datadir):
    try:
        sidebar = schema.ns("osaf.app", view).sidebarCollection

        for col in sidebar:
            if datadir == col.displayName:
                # We already imported these mail messages
                return

        files = pkg_resources.resource_listdir("debug", datadir)
        mCollection = SmartCollection(itsView=view)
        mCollection.displayName = unicode(datadir)

        for f in files:
            if not f.startswith("test_"):
                continue

            fp = pkg_resources.resource_stream("debug", "%s/%s" % (datadir, f))
            messageText = fp.read()
            fp.close()

            mailStamp = messageTextToKind(view, messageText)
            mCollection.add(mailStamp.itsItem)

        sidebar.add(mCollection)

    except:
        view.cancel()
        raise
Esempio n. 2
0
def loadMailTests(view, datadir):
    try:
        sidebar = schema.ns('osaf.app', view).sidebarCollection

        for col in sidebar:
            if datadir == col.displayName:
                #We already imported these mail messages
                return

        files = pkg_resources.resource_listdir('debug', datadir)
        mCollection = SmartCollection(itsView=view)
        mCollection.displayName = unicode(datadir)

        for f in files:
            if not f.startswith('test_'):
                continue

            fp = pkg_resources.resource_stream('debug', "%s/%s" % (datadir, f))
            messageText = fp.read()
            fp.close()

            mailStamp = messageTextToKind(view, messageText)
            mCollection.add(mailStamp.itsItem)

        sidebar.add(mCollection)

    except:
        view.cancel()
        raise
Esempio n. 3
0
    def testMessageTextToKind(self):
        mailKind = message.messageTextToKind(self.rep.view,
                                             self.__getMessageText())

        self.assertNotEqual(mailKind, None)

        self.__compareMailMessages(mailKind, self.__getMailMessage())
Esempio n. 4
0
    def setUp(self):
        super(TestReplyReplyAllForward, self).setUp()
        # Set the default timezone so that we'll get correct
        # format for dates in forwarded messages

        defaultTzinfo = self.view.tzinfo.getInstance("US/Hawaii")
        self.savedTzinfo = self.view.tzinfo.setDefault(defaultTzinfo)

        self.messageOne = message.messageTextToKind(self.view, self.M1)[1]
        self.messageTwo = message.messageTextToKind(self.view, self.M2)[1]
        self.messageThree = message.messageTextToKind(self.view, self.M3)[1]
        self.messageFour = message.messageTextToKind(self.view, self.M4)[1]

        self.assertTrue(isinstance(self.messageOne, MailStamp))
        self.assertTrue(isinstance(self.messageTwo, MailStamp))
        self.assertTrue(isinstance(self.messageThree, MailStamp))
        self.assertTrue(isinstance(self.messageFour, MailStamp))
        self.assertTrue(isinstance(self.messageFour, MailStamp))

        #This is also an event
        self.assertTrue(has_stamp(self.messageFour.itsItem, EventStamp))
    def testChangeCC(self):

        #        email = pim.mail.EmailAddress(itsParent=self.sandbox, fullName=u'Tommy Totoro',
        #                             emailAddress=u'*****@*****.**')

        mei = pim.mail.EmailAddress(itsParent=self.sandbox,
                                    fullName=u'Mei Kusakabe',
                                    emailAddress=u'*****@*****.**')

        catbus = pim.mail.EmailAddress(
            itsParent=self.sandbox,
            fullName=u'Nekobasu',
            emailAddress=u'*****@*****.**')

        mail = messageTextToKind(
            self.sandbox.itsView,
            "From: Nekobasu <[email protected]\r\n"
            "To: Mei Kusakabe <[email protected]\r\n"
            "Subject: Do you need a ride home?\r\n"
            "Content-Type: text/plain; charset='US-ASCII'"
            "\r\n"
            "I think it's raining!\r\n")[1]
        mail.itsItem.lastModification = pim.Modification.created

        pim.mail.getCurrentMeEmailAddresses(mei.itsView).add(mei)

        event = pim.EventStamp(mail)
        event.add()
        event.rruleset = self.rruleset

        pim.CHANGE_THIS(mail.itsItem).displayName = u"You bet I do!"

        firstItem = event.getFirstOccurrence().itsItem

        self.failIf(
            firstItem.hasLocalAttributeValue(
                pim.mail.MailStamp.ccAddress.name))

        self.failUnless(mei is mail.fromAddress)
        self.failUnless(catbus in mail.ccAddress)
Esempio n. 6
0
    def testChangeCC(self):

#        email = pim.mail.EmailAddress(itsParent=self.sandbox, fullName=u'Tommy Totoro',
#                             emailAddress=u'*****@*****.**')

        mei = pim.mail.EmailAddress(itsParent=self.sandbox, fullName=u'Mei Kusakabe',
                          emailAddress=u'*****@*****.**')

        catbus = pim.mail.EmailAddress(itsParent=self.sandbox,
                          fullName=u'Nekobasu',
                          emailAddress=u'*****@*****.**')

        mail = messageTextToKind(self.sandbox.itsView,
            "From: Nekobasu <[email protected]\r\n"
            "To: Mei Kusakabe <[email protected]\r\n"
            "Subject: Do you need a ride home?\r\n"
            "Content-Type: text/plain; charset='US-ASCII'"
            "\r\n"
            "I think it's raining!\r\n"
        )[1]
        mail.itsItem.lastModification = pim.Modification.created

        pim.mail.getCurrentMeEmailAddresses(mei.itsView).add(mei)

        event = pim.EventStamp(mail)
        event.add()
        event.rruleset = self.rruleset

        pim.CHANGE_THIS(mail.itsItem).displayName = u"You bet I do!"

        firstItem = event.getFirstOccurrence().itsItem

        self.failIf(firstItem.hasLocalAttributeValue(
                        pim.mail.MailStamp.ccAddress.name)
        )

        self.failUnless(mei is mail.fromAddress)
        self.failUnless(catbus in mail.ccAddress)
Esempio n. 7
0
def loadMailTests(view, dir):
    import osaf.mail.message as message

    mimeDir = os.path.join(Globals.chandlerDirectory, 'parcels', 'osaf', 'mail',
                           'tests', dir)

    files = os.listdir(mimeDir)

    for file in files:
        if not file.startswith('test_'):
            continue

        if message.verbose():
            logging.warn("Opening File: %s" % file)

        filename = os.path.join(mimeDir, file)

        fp = open(filename)
        messageText = fp.read()
        fp.close()

        mailMessage = message.messageTextToKind(view, messageText)

    view.commit()
Esempio n. 8
0
def loadMailTests(view, dir):
    import osaf.mail.message as message

    mimeDir = os.path.join(Globals.chandlerDirectory, 'parcels', 'osaf',
                           'mail', 'tests', dir)

    files = os.listdir(mimeDir)

    for file in files:
        if not file.startswith('test_'):
            continue

        if message.verbose():
            logging.warn("Opening File: %s" % file)

        filename = os.path.join(mimeDir, file)

        fp = open(filename)
        messageText = fp.read()
        fp.close()

        mailMessage = message.messageTextToKind(view, messageText)

    view.commit()
Esempio n. 9
0
    logger.ResumeProfiling()

    for case in INCOMING_TEST_CASES:
        try:
            action = None

            if len(case) == 3:
                file, logName, action = case
            else:
                file, logName = case

            mailText = loadMailFile(file)

            logger.Start(logName)

            item = messageTextToKind(view, mailText)
            ms = MailStamp(item)

            if action:
                if action == "E":
                    parseEventInfo(ms)
                elif action == "T":
                    parseTaskInfo(ms)

            ms.incomingMessage()

            # Commiting of a parsed message is
            # part of the performance metrics.
            view.commit()
            logger.Stop()
Esempio n. 10
0
 def testHTMLMessage(self):
     statusCode, mailStamp = message.messageTextToKind(self.view, self.M)
     self.assertEquals(mailStamp.body.strip(), \
                     u"Start of Body\n  \nMore text in red")
Esempio n. 11
0
 def testMessageWithEvent(self):
     statusCode, eventMessage = message.messageTextToKind(self.view,
                                    self.__getMultipartMessageText())
     self.assertTrue(has_stamp(eventMessage, MailStamp))
     self.assertTrue(has_stamp(eventMessage, EventStamp))
Esempio n. 12
0
    def testMessageTextToKind(self):
        statusCode, mailKind = message.messageTextToKind(self.view, self.__getMessageText())

        self.assertNotEqual(mailKind, None)

        self.__compareMailMessages(mailKind, self.__getMailMessage())
Esempio n. 13
0
 def testHTMLMessage(self):
     statusCode, mailStamp = message.messageTextToKind(self.view, self.M)
     self.assertEquals(mailStamp.body.strip(), \
                     u"Start of Body\n  \nMore text in red")
Esempio n. 14
0
    logger.ResumeProfiling()

    for case in INCOMING_TEST_CASES:
        try:
            action = None

            if len(case) == 3:
                file, logName, action = case
            else:
                file, logName = case

            mailText = loadMailFile(file)

            logger.Start(logName)

            item = messageTextToKind(view, mailText)
            ms = MailStamp(item)

            if action:
                if action == "E":
                    parseEventInfo(ms)
                elif action == "T":
                    parseTaskInfo(ms)

            ms.incomingMessage()

            # Commiting of a parsed message is
            # part of the performance metrics.
            view.commit()
            logger.Stop()