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 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_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)
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_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)
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 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)
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)
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()))
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)), [])
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'])
def test_noPrecedence(self): """ Test that an email message with no precedence header is focused. """ impl = Part() self._focusedTest(impl)
def createDatabase(s): Message(store=s, impl=Part(store=s), **attrs)