本文整理汇总了Python中spamfighter.core.domain.getDefaultDomain函数的典型用法代码示例。如果您正苦于以下问题:Python getDefaultDomain函数的具体用法?Python getDefaultDomain怎么用?Python getDefaultDomain使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getDefaultDomain函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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))
示例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)
示例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())
示例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
示例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)
示例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)
)
示例7: testDefaultDomain
def testDefaultDomain(self):
domain = getDefaultDomain()
self.assert_(IDomain.providedBy(domain))
self.assertEqual(None, domain.parent())
# у домена по умолчанию не может быть явных детей, т.к. он не допускает итерацию
return domain.children().addCallback(self.assertEqual, {})
示例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,
)
)
示例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)
)
示例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())
示例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']))
示例12: tearDown
def tearDown(self):
getDefaultDomain().delete('testMODEL')
示例13: setUp
def setUp(self):
self.c = FakeModelCommand()
self.model = BayesModel()
getDefaultDomain().set('testMODEL', self.model)
示例14: checkIt
def checkIt(rootDomain):
self.assert_(isinstance(rootDomain, BaseDomain))
self.assert_(rootDomain.parent() is getDefaultDomain())
示例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))