當前位置: 首頁>>代碼示例>>Python>>正文


Python Suspect.tags['testtag']方法代碼示例

本文整理匯總了Python中fuglu.shared.Suspect.tags['testtag']方法的典型用法代碼示例。如果您正苦於以下問題:Python Suspect.tags['testtag']方法的具體用法?Python Suspect.tags['testtag']怎麽用?Python Suspect.tags['testtag']使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在fuglu.shared.Suspect的用法示例。


在下文中一共展示了Suspect.tags['testtag']方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_sf_get_args

# 需要導入模塊: from fuglu.shared import Suspect [as 別名]
# 或者: from fuglu.shared.Suspect import tags['testtag'] [as 別名]
    def test_sf_get_args(self):
        """Test SuspectFilter files"""
        suspect = Suspect('[email protected]',
                          '[email protected]', TESTDATADIR + '/helloworld.eml')
        suspect.tags['testtag'] = 'testvalue'

        headermatches = self.candidate.get_args(suspect)
        self.assertTrue(
            'Sent to unittest domain!' in headermatches, "To_domain not found in headercheck")
        self.assertTrue('Envelope sender is [email protected]' in headermatches,
                        "Envelope Sender not matched in header chekc")
        self.assertTrue('Mime Version is 1.0' in headermatches,
                        "Standard header Mime Version not found")
        self.assertTrue(
            'A tag match' in headermatches, "Tag match did not work")
        self.assertTrue(
            'Globbing works' in headermatches, "header globbing failed")
        self.assertTrue(
            'body rule works' in headermatches, "decoded body rule failed")
        self.assertTrue(
            'full body rule works' in headermatches, "full body failed")
        self.assertTrue('mime rule works' in headermatches, "mime rule failed")
        self.assertFalse('this should not match in a body rule' in headermatches,
                         'decoded body rule matched raw body')

        # perl style advanced rules
        self.assertTrue('perl-style /-notation works!' in headermatches,
                        "new rule format failed: %s" % headermatches)
        self.assertTrue('perl-style recipient match' in headermatches,
                        "new rule format failed for to_domain: %s" % headermatches)
        self.assertFalse('this should not match' in headermatches,
                         "rule flag ignorecase was not detected")
開發者ID:steigr,項目名稱:fuglu,代碼行數:34,代碼來源:shared_test.py

示例2: test_hf

# 需要導入模塊: from fuglu.shared import Suspect [as 別名]
# 或者: from fuglu.shared.Suspect import tags['testtag'] [as 別名]
    def test_hf(self):
        """Test header filters"""

        suspect = Suspect('[email protected]',
                          '[email protected]', TESTDATADIR + '/helloworld.eml')
        suspect.tags['testtag'] = 'testvalue'

        headermatches = self.candidate.get_args(suspect)
        self.failUnless(
            'Sent to unittest domain!' in headermatches, "To_domain not found in headercheck")
        self.failUnless('Envelope sender is [email protected]' in headermatches,
                        "Envelope Sender not matched in header chekc")
        self.failUnless('Mime Version is 1.0' in headermatches,
                        "Standard header Mime Version not found")
        self.failUnless(
            'A tag match' in headermatches, "Tag match did not work")
        self.failUnless(
            'Globbing works' in headermatches, "header globbing failed")
        self.failUnless(
            'body rule works' in headermatches, "decoded body rule failed")
        self.failUnless(
            'full body rule works' in headermatches, "full body failed")
        self.failUnless('mime rule works' in headermatches, "mime rule failed")
        self.failIf('this should not match in a body rule' in headermatches,
                    'decoded body rule matched raw body')

        # perl style advanced rules
        self.failUnless('perl-style /-notation works!' in headermatches,
                        "new rule format failed: %s" % headermatches)
        self.failUnless('perl-style recipient match' in headermatches,
                        "new rule format failed for to_domain: %s" % headermatches)
        self.failIf('this should not match' in headermatches,
                    "rule flag ignorecase was not detected")

        # TODO: raw body rules

        # extended
        (match, info) = self.candidate.matches(suspect, extended=True)
        self.failUnless(match, 'Match should return True')
        field, matchedvalue, arg, regex = info
        self.failUnless(field == 'to_domain')
        self.failUnless(matchedvalue == 'unittests.fuglu.org')
        self.failUnless(arg == 'Sent to unittest domain!')
        self.failUnless(regex == 'unittests\.fuglu\.org')
開發者ID:sporkman,項目名稱:fuglu,代碼行數:46,代碼來源:shared_test.py


注:本文中的fuglu.shared.Suspect.tags['testtag']方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。