本文整理汇总了Python中fuglu.shared.Suspect.set_tag方法的典型用法代码示例。如果您正苦于以下问题:Python Suspect.set_tag方法的具体用法?Python Suspect.set_tag怎么用?Python Suspect.set_tag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fuglu.shared.Suspect
的用法示例。
在下文中一共展示了Suspect.set_tag方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_ignore_sender
# 需要导入模块: from fuglu.shared import Suspect [as 别名]
# 或者: from fuglu.shared.Suspect import set_tag [as 别名]
def test_ignore_sender(self):
from fuglu.shared import Suspect
v = Vacation()
v.ignoresender = u"unittests.fuglu.org [email protected]"
v.awayuser = u'[email protected]'
v.created = datetime.now()
v.start = datetime.now()
v.end = v.start + timedelta(days=2)
v.subject = u'gone for good'
v.body = u'outta here'
self.session.add(v)
self.session.flush()
self.session.expunge_all()
self.refreshcache()
suspect = Suspect(
'[email protected]', '[email protected]', '/dev/null')
suspect.set_tag('nobounce', True)
candidatevacation = self.candidate.on_vacation(suspect)
self.assertTrue(
candidatevacation != None, "Vacation object not found in database")
# TODO had to disable due to sqlalchemy error
# Instance <Vacation at 0x2938890> is not bound to a Session; attribute refresh operation cannot proceed
#self.assertEqual(v.ignoresender,candidatevacation.ignoresender,"Vacation object did not get ignore list")
self.assertTrue(self.candidate.ignore_sender(
candidatevacation, suspect), "Test Message should generate vacation reply(ignored sender)")
self.assertFalse(self.candidate.should_send_vacation_message(
suspect), "Sender on ignorelist, still wants to send message?!")
示例2: test_localpartblacklist
# 需要导入模块: from fuglu.shared import Suspect [as 别名]
# 或者: from fuglu.shared.Suspect import set_tag [as 别名]
def test_localpartblacklist(self):
"""test messages from mailer-daemon"""
from fuglu.shared import Suspect
import email
v = Vacation()
v.ignoresender = u""
v.awayuser = u'[email protected]'
v.created = datetime.now()
v.start = datetime.now()
v.end = v.start + timedelta(days=2)
v.subject = u'awaaay'
v.body = u'cya'
self.session.add(v)
self.session.flush()
self.session.expunge_all()
self.refreshcache()
botmsg = """From: [email protected]
Subject: mailinglist membership reminder...
"""
suspect = Suspect('[email protected]',
'[email protected]', '/dev/null')
suspect.set_tag('nobounce', True)
suspect.set_source(botmsg)
candidatevacation = self.candidate.on_vacation(suspect)
self.assertTrue(
candidatevacation != None, "Vacation object not found in database")
self.assertFalse(self.candidate.should_send_vacation_message(
suspect), "Test Message should NOT generate vacation reply(automated)")
示例3: test_vacation
# 需要导入模块: from fuglu.shared import Suspect [as 别名]
# 或者: from fuglu.shared.Suspect import set_tag [as 别名]
def test_vacation(self):
"""Test simple vacation use case"""
from fuglu.shared import Suspect
v = Vacation()
v.ignoresender = ""
v.awayuser = u'[email protected]'
v.created = datetime.now()
v.start = datetime.now()
v.end = v.start + timedelta(days=2)
v.subject = u'awaaay'
v.body = u'cya'
self.session.add(v)
self.session.flush()
self.session.expunge_all()
self.refreshcache()
suspect = Suspect(
u'[email protected]', '[email protected]', '/dev/null')
suspect.set_tag('nobounce', True)
candidatevacation = self.candidate.on_vacation(suspect)
self.assertTrue(
candidatevacation != None, "Vacation object not found in database")
self.assertTrue(self.candidate.should_send_vacation_message(
suspect), "Test Message should generate vacation reply")
self.candidate.log_bounce(suspect, candidatevacation)
# TODO: had to disable due to sqlalchemy error
# Instance <Vacation at 0x2938890> is not bound to a Session; attribute refresh operation cannot proceed
#self.assertFalse(self.candidate.should_send_vacation_message(suspect),"2nd test Message should NOT generate vacation reply")
suspect2 = Suspect(
u'[email protected]', '[email protected]', '/dev/null')
suspect2.set_tag('nobounce', True)
candidatevacation = self.candidate.on_vacation(suspect2)
self.assertFalse(candidatevacation != None,
"There should be no vacation object for this recipient")
self.assertFalse(self.candidate.should_send_vacation_message(
suspect2), "test Message should NOT generate vacation reply")
示例4: open
# 需要导入模块: from fuglu.shared import Suspect [as 别名]
# 或者: from fuglu.shared.Suspect import set_tag [as 别名]
open(tmpfile, 'w').write(mailmessage.as_string())
logging.info("Input file created as %s" % tmpfile)
suspect = Suspect(opts.sender, opts.recipients[0], tmpfile)
suspect.recipients = opts.recipients
# tags
if opts.tags:
for tagpair in opts.tags:
nme, valstr = tagpair.split(':', 1)
if valstr == 'TRUE':
val = True
elif valstr == 'FALSE':
val = False
else:
val = valstr
suspect.set_tag(nme, val)
scannerlist = mc.plugins
for pluginstance in mc.prependers:
logging.info("*** Running prepender: %s ***" % pluginstance)
result = pluginstance.pluginlist(suspect, scannerlist)
if result != None:
origset = set(scannerlist)
resultset = set(result)
removed = list(origset - resultset)
added = list(resultset - origset)
if len(removed) > 0:
logging.info(
'Prepender %s removed plugins: %s' % (pluginstance, list(map(str, removed))))
if len(added) > 0: