def test_processTrainingInstructions(self): """ When a user trains a message, a _TrainingInstruction item gets created to signal the batch processor to do the training. Make that gets run OK. """ f = Filter(store=self.store, usePostiniScore=True, postiniThreshhold=1.0) ti = _TrainingInstruction(store=self.store, spam=True) f.processItem(ti)
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 test_disablePostiniHamFiltering(self): """ Test that if C{usePostiniScore} is False the header is ignored and another filter is consulted. """ msg = self._messageWithPostiniHeader(u"(S: 0.9000 R:95.9108 P:91.9078 M:100.0000 C:96.6797 )") f = Filter(store=self.store, usePostiniScore=False, postiniThreshhold=None) installOn(TestFilter(store=self.store, result=False), self.store) f.processItem(msg) self.failIf(msg.hasStatus(SPAM_STATUS))
def test_postiniHeaderSpamFiltering(self): """ Test that if a message has a low enough spam level in a Postini C{X-pstn-levels} header and the Filter has been configured to use it, it is classified as spam. """ msg = self._messageWithPostiniHeader(u"(S: 0.9000 R:95.9108 P:91.9078 M:100.0000 C:96.6797 )") f = Filter(usePostiniScore=True, postiniThreshhold=1.0) f.processItem(msg) self.failUnless(msg.hasStatus(SPAM_STATUS))
def test_postiniHeaderSpamFiltering(self): """ Test that if a message has a low enough spam level in a Postini C{X-pstn-levels} header and the Filter has been configured to use it, it is classified as spam. """ msg = self._messageWithPostiniHeader( u'(S: 0.9000 R:95.9108 P:91.9078 M:100.0000 C:96.6797 )') f = Filter(usePostiniScore=True, postiniThreshhold=1.0) f.processItem(msg) self.failUnless(msg.hasStatus(SPAM_STATUS))
def test_postiniRespectsTraining(self): """ If a user trains a message as ham or spam, the postini code should not clobber that value, even though postini is not really trainable itself. """ msg = self._messageWithPostiniHeader(u"(S:99.9000 R:95.9108 P:91.9078 M:100.0000 C:96.6797 )") msg.trainSpam() f = Filter(store=self.store, usePostiniScore=True, postiniThreshhold=1.0) f.processItem(msg) self.failUnless(msg.hasStatus(SPAM_STATUS)) self.failIf(msg.shouldBeClassified)
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 test_disablePostiniHamFiltering(self): """ Test that if C{usePostiniScore} is False the header is ignored and another filter is consulted. """ msg = self._messageWithPostiniHeader( u'(S: 0.9000 R:95.9108 P:91.9078 M:100.0000 C:96.6797 )') f = Filter(store=self.store, usePostiniScore=False, postiniThreshhold=None) installOn(TestFilter(store=self.store, result=False), self.store) f.processItem(msg) self.failIf(msg.hasStatus(SPAM_STATUS))
def test_postiniRespectsTraining(self): """ If a user trains a message as ham or spam, the postini code should not clobber that value, even though postini is not really trainable itself. """ msg = self._messageWithPostiniHeader( u'(S:99.9000 R:95.9108 P:91.9078 M:100.0000 C:96.6797 )') msg.trainSpam() f = Filter(store=self.store, usePostiniScore=True, postiniThreshhold=1.0) f.processItem(msg) self.failUnless(msg.hasStatus(SPAM_STATUS)) self.failIf(msg.shouldBeClassified)