• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python domain.getDefaultDomain函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中spamfighter.core.domain.getDefaultDomain函数的典型用法代码示例。如果您正苦于以下问题:Python getDefaultDomain函数的具体用法?Python getDefaultDomain怎么用?Python getDefaultDomain使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了getDefaultDomain函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: testCheckLength

    def testCheckLength(self):
        self.assertTrue(lengthCheck(domain=getDefaultDomain(), message=self.message1))

        self.assertFalse(lengthCheck(domain=getDefaultDomain(), message=self.message1, minLength=64))
        self.assertTrue(lengthCheck(domain=getDefaultDomain(), message=self.message1, minLength=10))

        self.assertTrue(lengthCheck(domain=getDefaultDomain(), message=self.message1, maxLength=64))
        self.assertFalse(lengthCheck(domain=getDefaultDomain(), message=self.message1, maxLength=10))
开发者ID:pombredanne,项目名称:spamfighter,代码行数:8,代码来源:test_validate.py


示例2: setUp

    def setUp(self):
        getDefaultDomain().set('testStorage', DomainMemoryStorage(storage=MemoryStorage(cleanupInterval=0)))

        self.message1 = TransitMessage(serialized={ 'text' : u'мама мыла раму папы', 'ip': '192.168.140.4'}).getMessage(getDefaultDomain())
        self.message2 = TransitMessage(serialized={ 'text' : u'папа'}).getMessage(getDefaultDomain())
        self.message3 = TransitMessage(serialized={ 'text' : u'привет всем в чате!', 'from': 15}).getMessage(getDefaultDomain())
        self.message4 = TransitMessage(serialized={ 'text' : u'и тебе привет!', 'from': 16, 'ip': '192.168.140.4'}).getMessage(getDefaultDomain())
        startUpTestTimer(1000)
开发者ID:pombredanne,项目名称:spamfighter,代码行数:8,代码来源:test_frequency.py


示例3: setUp

    def setUp(self):
        model = BayesModel()
        model.train(u"мама мыла раму", True)
        model.train(u"папа пошел гулять", False)
        getDefaultDomain().set('testModel', model)

        self.message1 = TransitMessage(serialized={ 'text' : u'мама'}).getMessage(getDefaultDomain())
        self.message2 = TransitMessage(serialized={ 'text' : u'папа'}).getMessage(getDefaultDomain())
开发者ID:pombredanne,项目名称:spamfighter,代码行数:8,代码来源:test_model.py


示例4: testCountIPMessages

    def testCountIPMessages(self):
        d = defer.succeed(None)

        for i in xrange(15):
            d.addCallback(lambda _: userFrequencyCheck(domain=getDefaultDomain(), message=self.message4, attribute="ip", storage="testStorage", count=16, timeout=10). \
                addCallback(self.assertTrue))

        d.addCallback(lambda _: userFrequencyCheck(domain=getDefaultDomain(), message=self.message4, attribute="ip", storage="testStorage", count=16, timeout=10). \
            addCallback(self.assertFalse)).addCallback(lambda _: advanceTestTimer(10)). \
        addCallback(lambda _: userFrequencyCheck(domain=getDefaultDomain(), message=self.message4, attribute="ip", storage="testStorage", count=16, timeout=10). \
            addCallback(self.assertTrue))

        return d
开发者ID:pombredanne,项目名称:spamfighter,代码行数:13,代码来源:test_frequency.py


示例5: setUp

    def setUp(self):
        getDefaultDomain().set('testStorage', DomainMemoryStorage(storage=MemoryStorage(cleanupInterval=0)))

        self.message1 = TransitMessage(serialized={ 'text' : u'мама мыла раму папы'}).getMessage(getDefaultDomain())
        self.message2 = TransitMessage(serialized={ 'text' : u'папа'}).getMessage(getDefaultDomain())
        self.message3 = TransitMessage(serialized={ 'text' : u'привет всем в чате!'}).getMessage(getDefaultDomain())
        self.message4 = TaggedMessage(TransitMessage(serialized={ 'text' : u'и тебе привет!',}).getMessage(getDefaultDomain()))
        self.message4.addTag('good')
        self.message4.addTag('bad')

        startUpTestTimer(1000)

        self.log = MessageLog(storage='testStorage')
        getDefaultDomain().set('testLog', self.log)
开发者ID:pombredanne,项目名称:spamfighter,代码行数:14,代码来源:test_log.py


示例6: testSetRules

 def testSetRules(self):
     firewall = MessageFirewall()
     message = TaggedMessage([])
     firewall.setRules("stop as NEW")
     return firewall.analyze(message, getDefaultDomain()).addCallback(
         lambda result: self.assertEquals("NEW", result)
     )
开发者ID:pombredanne,项目名称:spamfighter,代码行数:7,代码来源:test_firewall.py


示例7: testDefaultDomain

    def testDefaultDomain(self):
        domain = getDefaultDomain()

        self.assert_(IDomain.providedBy(domain))
        self.assertEqual(None, domain.parent())
        # у домена по умолчанию не может быть явных детей, т.к. он не допускает итерацию
        return domain.children().addCallback(self.assertEqual, {})
开发者ID:pombredanne,项目名称:spamfighter,代码行数:7,代码来源:test_domain.py


示例8: testDebug

    def testDebug(self):
        firewall = MessageFirewall(
            "do ruleTrue() mark xxx\nif not xxx do ruleFalse() mark zzz\nskip to 100\n200: stop as C\n100: if yyyy stop as D\nif xx stop as A\nstop as B"
        )
        message = TaggedMessage([])

        def logCallback(log):
            self.fwLog = log

        return firewall.analyze(message, getDefaultDomain(), debug=True, logCallback=logCallback).addCallback(
            lambda _: self.assertEquals(
                [
                    "[ENTER]: do ruleTrue() mark xxx",
                    "Result: True",
                    "[ENTER]: if not xxx do ruleFalse() mark zzz",
                    "Result: False",
                    "Tagged message with tags: ['zzz'], current tags are: ['zzz']",
                    "[ENTER]: skip to 100",
                    "Skipping to 100",
                    "Labels for skip don't match 100 != 200",
                    "Stopped skip to at label 100",
                    "[ENTER]: 100: if yyyy stop as D",
                    "[ENTER]: if xx stop as A",
                    "[ENTER]: stop as B",
                    "Stopping firewall with result: B",
                ],
                self.fwLog,
            )
        )
开发者ID:pombredanne,项目名称:spamfighter,代码行数:29,代码来源:test_firewall.py


示例9: testAnalyze5

    def testAnalyze5(self):
        firewall = MessageFirewall("10: do ruleTrue()\nskip to 10")
        message = TaggedMessage([])

        def checkSkipFall(failure):
            failure.trap(errors.SkipToFallthroughError)

        return (
            firewall.analyze(message, getDefaultDomain())
            .addCallback(lambda _: self.assert_(False))
            .addErrback(checkSkipFall)
        )
开发者ID:pombredanne,项目名称:spamfighter,代码行数:12,代码来源:test_firewall.py


示例10: setUp

    def setUp(self):
        startUpTestTimer(100)
        getDefaultDomain().set('testStorage', DomainMemoryStorage(storage=MemoryStorage(cleanupInterval=0)))
        self.log = MessageLog(storage='testStorage')
        getDefaultDomain().set('testLog', self.log)

        self.message1 = TransitMessage(serialized={ 'text' : u'мама'}).getMessage(getDefaultDomain())
        self.message2 = TransitMessage(serialized={ 'text' : u'папа'}).getMessage(getDefaultDomain())
开发者ID:pombredanne,项目名称:spamfighter,代码行数:8,代码来源:test_log.py


示例11: setUp

    def setUp(self):
        startUpTestTimer(100)
        getDefaultDomain().set('testStorage', DomainMemoryStorage(storage=MemoryStorage(cleanupInterval=0)))
        self.log = MessageLog(storage='testStorage')
        getDefaultDomain().set('testLog', self.log)

        self.message1 = TransitMessage(serialized={ 'text' : u'мама'}).getMessage(getDefaultDomain())
        self.message2 = TransitMessage(serialized={ 'text' : u'папа'}).getMessage(getDefaultDomain())

        self.c = MessageLogFetchCommand()
        self.c.params.getUnserialized({'partner' : None, 'log' : 'testLog'})

        return self.log.put(message=self.message1, when=90).addCallback(lambda _: self.log.put(message=self.message2, when=95, tags=['aaa']))
开发者ID:pombredanne,项目名称:spamfighter,代码行数:13,代码来源:test_log.py


示例12: tearDown

 def tearDown(self):
     getDefaultDomain().delete('testMODEL')
开发者ID:pombredanne,项目名称:spamfighter,代码行数:2,代码来源:test_command.py


示例13: setUp

 def setUp(self):
     self.c = FakeModelCommand()
     self.model = BayesModel()
     getDefaultDomain().set('testMODEL', self.model)
开发者ID:pombredanne,项目名称:spamfighter,代码行数:4,代码来源:test_command.py


示例14: checkIt

 def checkIt(rootDomain):
     self.assert_(isinstance(rootDomain, BaseDomain))
     self.assert_(rootDomain.parent() is getDefaultDomain())
开发者ID:pombredanne,项目名称:spamfighter,代码行数:3,代码来源:test_null_partner.py


示例15: testAnalyzeMessage

 def testAnalyzeMessage(self):
     self.assertFalse(messageFloodCheck(domain=getDefaultDomain(), message=self.message5))
     self.assertTrue(messageFloodCheck(domain=getDefaultDomain(), message=self.message5, minLength=30))
     self.assertFalse(messageFloodCheck(domain=getDefaultDomain(), message=self.message6))
开发者ID:pombredanne,项目名称:spamfighter,代码行数:4,代码来源:test_analyze.py


示例16: testHasAttribute

 def testHasAttribute(self):
     self.assertFalse(hasAttribute(domain=getDefaultDomain(), message=self.message1, attribute='from'))
     self.assertTrue(hasAttribute(domain=getDefaultDomain(), message=self.message3, attribute='from'))
开发者ID:pombredanne,项目名称:spamfighter,代码行数:3,代码来源:test_validate.py


示例17: testAnalyze7

 def testAnalyze7(self):
     firewall = MessageFirewall("do ruleTrue() mark xxx\nif xx stop as A\nstop as B")
     message = TaggedMessage([])
     return firewall.analyze(message, getDefaultDomain()).addCallback(lambda result: self.assertEquals("B", result))
开发者ID:pombredanne,项目名称:spamfighter,代码行数:4,代码来源:test_firewall.py


示例18: testNoLog

 def testNoLog(self):
     return defer.maybeDeferred(messageLogPut, log="__noSUCHLOG__", domain=getDefaultDomain(), message=self.message1).addCallback(lambda _: self.assert_(False)) \
             .addErrback(lambda failure: failure.trap("spamfighter.core.commands.errors.AttributeKeyException"))
开发者ID:pombredanne,项目名称:spamfighter,代码行数:3,代码来源:test_log.py


示例19: tearDown

 def tearDown(self):
     tearDownTestTimer()
     getDefaultDomain().delete('testStorage')
     getDefaultDomain().delete('testLog')
开发者ID:pombredanne,项目名称:spamfighter,代码行数:4,代码来源:test_log.py


示例20: tearDown

 def tearDown(self):
     getDefaultDomain().delete('testVALUE')
     getDefaultDomain().delete('testOBJECT')
开发者ID:pombredanne,项目名称:spamfighter,代码行数:3,代码来源:test_get.py



注:本文中的spamfighter.core.domain.getDefaultDomain函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python spams.lasso函数代码示例发布时间:2022-05-27
下一篇:
Python tokenizer.tokenize函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap