Esempio n. 1
0
 def _messageWithPostiniHeader(self, header):
     part = Part()
     part.addHeader(u"X-pstn-levels", unicode(header))
     msg = Message(store=self.store)
     # part._addToStore(self.store, msg, None)
     part.associateWithMessage(msg)
     msg.impl = part
     return msg
 def test_otherPrecedence(self):
     """
     Test that an email message with some random other precedence header
     value is focused.
     """
     impl = Part()
     impl.addHeader(u'Precedence', u'made up random value')
     self._focusedTest(impl)
Esempio n. 3
0
 def test_otherPrecedence(self):
     """
     Test that an email message with some random other precedence header
     value is focused.
     """
     impl = Part()
     impl.addHeader(u'Precedence', u'made up random value')
     self._focusedTest(impl)
Esempio n. 4
0
 def setUp(self):
     """
     Create a store and a MIME message with a message/rfc822 attachment.
     """
     self.dbdir = self.mktemp()
     self.store = Store(dbdir=self.dbdir)
     partCounter = itertools.count().next
     self.parent = Part(_partCounter=partCounter)
     msgContainer = self.parent.newChild()
     msgContainer.addHeader(u"content-type", u"message/rfc822")
     msgContainer.addHeader(u"content-disposition", u"inline")
     self.msg = msgContainer.newChild()
def createDatabase(s):
    Image(store=s,
          part=Part(store=s),
          message=Message(store=s,
                          subject=u'Hello!'),
          mimeType=u'foo/bar',
          thumbnailPath=s.newFilePath('foo', 'bar'))
    def test_bulkPrecedence(self):
        """
        Test that an email message with C{bulk} precedence is not focused.
        """
        impl = Part()
        impl.addHeader(u'Precedence', u'bulk')
        self._unfocusedTest(impl)

        impl = Part()
        impl.addHeader(u'Precedence', u'BuLK')
        self._unfocusedTest(impl)
    def test_listPrecedence(self):
        """
        Test that an email message with C{list} precedence is not focused.
        """
        impl = Part()
        impl.addHeader(u'Precedence', u'list')
        self._unfocusedTest(impl)

        impl = Part()
        impl.addHeader(u'Precedence', u'LIsT')
        self._unfocusedTest(impl)
 def test_draft(self):
     """
     Verify that a draft is not focused.
     """
     impl = Part()
     message = Message.createDraft(self.userStore, impl,
                                   u'test://test_draft')
     self.focus.processItem(message)
     statuses = set(message.iterStatuses())
     self.failIfIn(FOCUS_STATUS, statuses)
 def test_outbox(self):
     """
     Verify that a message in the outbox is not focused.
     """
     impl = Part()
     message = Message.createDraft(self.userStore, impl,
                                   u'test://test_outbox')
     message.startedSending()
     self.focus.processItem(message)
     statuses = set(message.iterStatuses())
     self.failIfIn(FOCUS_STATUS, statuses)
Esempio n. 10
0
 def setUp(self):
     """
     Create a store and a MIME message with a message/rfc822 attachment.
     """
     self.dbdir = self.mktemp()
     self.store = Store(dbdir=self.dbdir)
     partCounter = itertools.count().next
     self.parent = Part(_partCounter=partCounter)
     msgContainer = self.parent.newChild()
     msgContainer.addHeader(u"content-type", u"message/rfc822")
     msgContainer.addHeader(u"content-disposition", u"inline")
     self.msg = msgContainer.newChild()
Esempio n. 11
0
 def test_bounced(self):
     """
     Verify that a message which has bounced is not focused.
     """
     impl = Part()
     message = Message.createDraft(self.userStore, impl,
                                   u'test://test_bounced')
     message.startedSending()
     message.allBounced()
     self.focus.processItem(message)
     statuses = set(message.iterStatuses())
     self.failIfIn(FOCUS_STATUS, statuses)
Esempio n. 12
0
 def test_postiniWithoutHeaderHamFiltering(self):
     """
     Check that when postini filtering is enabled but a message has no
     postini header then the other filter is consulted.
     """
     msg = Message.createIncoming(
         self.store, Part(), u'test://postiniWithoutHeaderHamFiltering')
     f = Filter(store=self.store,
                usePostiniScore=True,
                postiniThreshhold=1.0)
     installOn(TestFilter(store=self.store, result=False), self.store)
     f.processItem(msg)
     self.assertNotIn(SPAM_STATUS, list(msg.iterStatuses()))
Esempio n. 13
0
 def test_partiallySent(self):
     """
     Verify that a message which has been sent to one recipient is not
     focused.
     """
     impl = Part()
     message = Message.createDraft(self.userStore, impl,
                                   u'test://test_partiallySent')
     message.startedSending()
     message.sent()
     self.focus.processItem(message)
     statuses = set(message.iterStatuses())
     self.failIfIn(FOCUS_STATUS, statuses)
Esempio n. 14
0
 def _messageWithPostiniHeader(self, header):
     part = Part()
     part.addHeader(u'X-pstn-levels', unicode(header))
     msg = Message(store=self.store)
     # part._addToStore(self.store, msg, None)
     part.associateWithMessage(msg)
     msg.impl = part
     return msg
Esempio n. 15
0
    def testEZMLMFilter(self):
        """
        Ensure that match_EZMLM doesn't kerplode when presented with a
        header that doesn't parse well.
        """
        part = Part()
        part.addHeader(u'X-Mailman-Version', u"2.1.5")
        part.addHeader(u'List-Post', u"Random bytes")
        part.source = FilePath(self.storepath).child("files").child("x")
        msg = Message.createIncoming(self.store, part,
                                     u'test://test_mailing_list_filter')

        self.mlfp.processItem(msg)
        self.assertEqual(list(self.tagcatalog.tagsOf(msg)), [])
Esempio n. 16
0
    def test_bulkPrecedence(self):
        """
        Test that an email message with C{bulk} precedence is not focused.
        """
        impl = Part()
        impl.addHeader(u'Precedence', u'bulk')
        self._unfocusedTest(impl)

        impl = Part()
        impl.addHeader(u'Precedence', u'BuLK')
        self._unfocusedTest(impl)
Esempio n. 17
0
    def test_listPrecedence(self):
        """
        Test that an email message with C{list} precedence is not focused.
        """
        impl = Part()
        impl.addHeader(u'Precedence', u'list')
        self._unfocusedTest(impl)

        impl = Part()
        impl.addHeader(u'Precedence', u'LIsT')
        self._unfocusedTest(impl)
Esempio n. 18
0
    def testEZMLMFilter(self):
        """
        Ensure that match_EZMLM doesn't kerplode when presented with a
        header that doesn't parse well.
        """
        part = Part()
        part.addHeader(u'X-Mailman-Version', u"2.1.5")
        part.addHeader(u'List-Post',
                       u"Random bytes")
        part.source = FilePath(self.storepath).child("files").child("x")
        msg = Message.createIncoming(self.store, part,
                                     u'test://test_mailing_list_filter')

        self.mlfp.processItem(msg)
        self.assertEqual(list(self.tagcatalog.tagsOf(msg)),
                         [])
Esempio n. 19
0
    def testMailingListFilter(self):
        """
        Ensures that mailing list messages are not handled by
        RuleFilteringPowerup but are handled by MailingListFilteringPowerup.
        """

        part = Part()
        part.addHeader(u'X-Mailman-Version', u"2.1.5")
        part.addHeader(u'List-Id',
                       u"Some mailing list <some-list.example.com>")
        part.source = FilePath(self.storepath).child("files").child("x")
        msg = Message.createIncoming(self.store, part,
                                     u'test://test_mailing_list_filter')

        self.rfp.processItem(msg)
        self.assertEqual(list(self.tagcatalog.tagsOf(msg)), [])

        self.mlfp.processItem(msg)
        self.assertEqual(list(self.tagcatalog.tagsOf(msg)),
                         [u'some-list.example.com'])
Esempio n. 20
0
    def testMailingListFilter(self):
        """
        Ensures that mailing list messages are not handled by
        RuleFilteringPowerup but are handled by MailingListFilteringPowerup.
        """

        part = Part()
        part.addHeader(u'X-Mailman-Version', u"2.1.5")
        part.addHeader(u'List-Id',
                       u"Some mailing list <some-list.example.com>")
        part.source = FilePath(self.storepath).child("files").child("x")
        msg = Message.createIncoming(self.store, part,
                                     u'test://test_mailing_list_filter')

        self.rfp.processItem(msg)
        self.assertEqual(list(self.tagcatalog.tagsOf(msg)), [])

        self.mlfp.processItem(msg)
        self.assertEqual(list(self.tagcatalog.tagsOf(msg)),
                         [u'some-list.example.com'])
Esempio n. 21
0
class PartWrapperTestCase(TestCase):
    """
    Tests for L{xquotient.exmess.MessageWrapperForPart}.
    """
    def setUp(self):
        """
        Create a store and a MIME message with a message/rfc822 attachment.
        """
        self.dbdir = self.mktemp()
        self.store = Store(dbdir=self.dbdir)
        partCounter = itertools.count().next
        self.parent = Part(_partCounter=partCounter)
        msgContainer = self.parent.newChild()
        msgContainer.addHeader(u"content-type", u"message/rfc822")
        msgContainer.addHeader(u"content-disposition", u"inline")
        self.msg = msgContainer.newChild()

    def createMIMEStructure(self):
        """
        Insert some contents into the attached message.
        """
        self.msg.addHeader(u"from", u"*****@*****.**")
        self.msg.addHeader(u"to", u"*****@*****.**")
        self.msg.addHeader(u"date", u"Fri, 13 Feb 2004 13:43:48 +0100")
        self.msg.addHeader(u"content-type", u"multipart/mixed")
        self.msg.addHeader(u"subject", u"Awesome Email")
        subpart = self.msg.newChild()
        subpart.addHeader(u"content-type", u"text/html")
        attachment = self.msg.newChild()
        attachment.addHeader(u"content-type", u"image/png")
        attachment.addHeader(u"content-disposition",
                             u'attachment; filename="foo.png"')

        self.parent._addToStore(
            self.store, Message(store=self.store),
            FilePath(self.dbdir).child("files").child("msg"))
        self.wrapper = MessageWrapperForPart(self.msg, Time())

    def test_wrapperAttributes(self):
        """
        Test that wrapper attributes are sufficiently like Message's.
        """
        self.createMIMEStructure()
        self.assertEqual(self.wrapper.impl, self.msg)
        self.assertEqual(self.wrapper.recipient, u'*****@*****.**')
        self.assertEqual(self.wrapper.sender, u'*****@*****.**')
        self.assertEqual(self.wrapper.subject, u'Awesome Email')

    def test_moreWrapperAttributes(self):
        """
        Test that wrapper attributes are sufficiently like Message's
        when certain headers aren't present.
        """
        self.msg.addHeader(u"from", u"*****@*****.**")
        self.msg.addHeader(u"date", u"Fri, 13 Feb 2004 13:43:48 +0100")
        self.msg.addHeader(u"content-type", u"multipart/mixed")
        subpart = self.msg.newChild()
        subpart.addHeader(u"content-type", u"text/html")
        attachment = self.msg.newChild()
        attachment.addHeader(u"content-type", u"image/png")
        attachment.addHeader(u"content-disposition",
                             u'attachment; filename="foo.png"')

        self.parent._addToStore(
            self.store, Message(store=self.store),
            FilePath(self.dbdir).child("files").child("msg"))
        self.wrapper = MessageWrapperForPart(self.msg, Time())
        self.assertEqual(self.wrapper.recipient, u'<No Recipient>')
        self.assertEqual(self.wrapper.subject, u'<No Subject>')

    def test_wrapperWalkAttachments(self):
        """
        Test that walkAttachments on the message/rfc822 part returns
        the same thing as the wrapper's walkAttachments.
        """
        self.createMIMEStructure()
        self.assertEqual([m.part for m in self.wrapper.walkAttachments()],
                         [m.part for m in self.msg.walkAttachments()])

    def test_wrapperWalkMessage(self):
        """
        Test that walkMessage on the message/rfc822 part returns the
        same thing as the wrapper's walkMessage.
        """
        self.createMIMEStructure()
        self.assertEqual(
            [m.part for m in self.wrapper.walkMessage('text/html')],
            [m.part for m in self.msg.walkMessage('text/html')])

    def test_actions(self):
        """
        Ensure that no action buttons get rendered.
        """
        self.createMIMEStructure()
        self.assertEqual(self.wrapper.getActions(), [])

    def test_noSender(self):
        """
        Test that a message with no sender headers gets handled properly.
        """
        self.msg.addHeader(u"to", u"*****@*****.**")
        self.msg.addHeader(u"date", u"Fri, 13 Feb 2004 13:43:48 +0100")
        self.msg.addHeader(u"content-type", u"multipart/mixed")
        self.msg.addHeader(u"subject", u"Awesome Email")
        self.wrapper = MessageWrapperForPart(self.msg, Time())
        self.assertEqual(self.wrapper.sender, u'')
        self.assertEqual(self.wrapper.senderDisplay, u'')
Esempio n. 22
0
class PartWrapperTestCase(TestCase):
    """
    Tests for L{xquotient.exmess.MessageWrapperForPart}.
    """
    def setUp(self):
        """
        Create a store and a MIME message with a message/rfc822 attachment.
        """
        self.dbdir = self.mktemp()
        self.store = Store(dbdir=self.dbdir)
        partCounter = itertools.count().next
        self.parent = Part(_partCounter=partCounter)
        msgContainer = self.parent.newChild()
        msgContainer.addHeader(u"content-type", u"message/rfc822")
        msgContainer.addHeader(u"content-disposition", u"inline")
        self.msg = msgContainer.newChild()


    def createMIMEStructure(self):
        """
        Insert some contents into the attached message.
        """
        self.msg.addHeader(u"from", u"*****@*****.**")
        self.msg.addHeader(u"to", u"*****@*****.**")
        self.msg.addHeader(u"date", u"Fri, 13 Feb 2004 13:43:48 +0100")
        self.msg.addHeader(u"content-type", u"multipart/mixed")
        self.msg.addHeader(u"subject", u"Awesome Email")
        subpart = self.msg.newChild()
        subpart.addHeader(u"content-type", u"text/html")
        attachment = self.msg.newChild()
        attachment.addHeader(u"content-type", u"image/png")
        attachment.addHeader(u"content-disposition",
                             u'attachment; filename="foo.png"')

        self.parent._addToStore(self.store,
                           Message(store=self.store),
                           FilePath(self.dbdir).child("files").child("msg"))
        self.wrapper = MessageWrapperForPart(self.msg, Time())


    def test_wrapperAttributes(self):
        """
        Test that wrapper attributes are sufficiently like Message's.
        """
        self.createMIMEStructure()
        self.assertEqual(self.wrapper.impl, self.msg)
        self.assertEqual(self.wrapper.recipient, u'*****@*****.**')
        self.assertEqual(self.wrapper.sender, u'*****@*****.**')
        self.assertEqual(self.wrapper.subject, u'Awesome Email')


    def test_moreWrapperAttributes(self):
        """
        Test that wrapper attributes are sufficiently like Message's
        when certain headers aren't present.
        """
        self.msg.addHeader(u"from", u"*****@*****.**")
        self.msg.addHeader(u"date", u"Fri, 13 Feb 2004 13:43:48 +0100")
        self.msg.addHeader(u"content-type", u"multipart/mixed")
        subpart = self.msg.newChild()
        subpart.addHeader(u"content-type", u"text/html")
        attachment = self.msg.newChild()
        attachment.addHeader(u"content-type", u"image/png")
        attachment.addHeader(u"content-disposition",
                             u'attachment; filename="foo.png"')

        self.parent._addToStore(self.store,
                           Message(store=self.store),
                           FilePath(self.dbdir).child("files").child("msg"))
        self.wrapper = MessageWrapperForPart(self.msg, Time())
        self.assertEqual(self.wrapper.recipient, u'<No Recipient>')
        self.assertEqual(self.wrapper.subject, u'<No Subject>')


    def test_wrapperWalkAttachments(self):
        """
        Test that walkAttachments on the message/rfc822 part returns
        the same thing as the wrapper's walkAttachments.
        """
        self.createMIMEStructure()
        self.assertEqual([m.part for m in self.wrapper.walkAttachments()],
                         [m.part for m in self.msg.walkAttachments()])


    def test_wrapperWalkMessage(self):
        """
        Test that walkMessage on the message/rfc822 part returns the
        same thing as the wrapper's walkMessage.
        """
        self.createMIMEStructure()
        self.assertEqual([m.part for m in
                          self.wrapper.walkMessage('text/html')],
                         [m.part for m in self.msg.walkMessage('text/html')])


    def test_actions(self):
        """
        Ensure that no action buttons get rendered.
        """
        self.createMIMEStructure()
        self.assertEqual(self.wrapper.getActions(), [])


    def test_noSender(self):
        """
        Test that a message with no sender headers gets handled properly.
        """
        self.msg.addHeader(u"to", u"*****@*****.**")
        self.msg.addHeader(u"date", u"Fri, 13 Feb 2004 13:43:48 +0100")
        self.msg.addHeader(u"content-type", u"multipart/mixed")
        self.msg.addHeader(u"subject", u"Awesome Email")
        self.wrapper = MessageWrapperForPart(self.msg, Time())
        self.assertEqual(self.wrapper.sender, u'')
        self.assertEqual(self.wrapper.senderDisplay, u'')
Esempio n. 23
0
def createDatabase(s):
    Message(store=s,
            impl=Part(store=s),
            **attrs)
Esempio n. 24
0
 def test_noPrecedence(self):
     """
     Test that an email message with no precedence header is focused.
     """
     impl = Part()
     self._focusedTest(impl)