本文整理汇总了Python中fuglu.shared.Suspect.setMessageRep方法的典型用法代码示例。如果您正苦于以下问题:Python Suspect.setMessageRep方法的具体用法?Python Suspect.setMessageRep怎么用?Python Suspect.setMessageRep使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fuglu.shared.Suspect
的用法示例。
在下文中一共展示了Suspect.setMessageRep方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_result
# 需要导入模块: from fuglu.shared import Suspect [as 别名]
# 或者: from fuglu.shared.Suspect import setMessageRep [as 别名]
def test_result(self):
"""Test if EICAR virus is detected and message deleted"""
suspect = Suspect(
'[email protected]', '[email protected]', '/dev/null')
stream = """Date: Mon, 08 Sep 2008 17:33:54 +0200
To: [email protected]
From: [email protected]
Subject: test eicar attachment
X-Mailer: swaks v20061116.0 jetmore.org/john/code/#swaks
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="----=_MIME_BOUNDARY_000_12140"
------=_MIME_BOUNDARY_000_12140
Content-Type: text/plain
Eicar test
------=_MIME_BOUNDARY_000_12140
Content-Type: application/octet-stream
Content-Transfer-Encoding: BASE64
Content-Disposition: attachment
UEsDBAoAAAAAAGQ7WyUjS4psRgAAAEYAAAAJAAAAZWljYXIuY29tWDVPIVAlQEFQWzRcUFpYNTQo
UF4pN0NDKTd9JEVJQ0FSLVNUQU5EQVJELUFOVElWSVJVUy1URVNULUZJTEUhJEgrSCoNClBLAQIU
AAoAAAAAAGQ7WyUjS4psRgAAAEYAAAAJAAAAAAAAAAEAIAD/gQAAAABlaWNhci5jb21QSwUGAAAA
AAEAAQA3AAAAbQAAAAAA
------=_MIME_BOUNDARY_000_12140--"""
suspect.setMessageRep(email.message_from_string(stream))
result = self.candidate.examine(suspect)
if type(result) is tuple:
result, message = result
strresult = actioncode_to_string(result)
self.assertEqual(strresult, "DELETE")
示例2: test_modified_message
# 需要导入模块: from fuglu.shared import Suspect [as 别名]
# 或者: from fuglu.shared.Suspect import setMessageRep [as 别名]
def test_modified_message(self):
"""Test if the modified message gets archived correctly"""
from fuglu.shared import Suspect
import shutil
import tempfile
tempfilename = tempfile.mktemp(
suffix='archive', prefix='fuglu-unittest', dir='/tmp')
shutil.copy(TESTDATADIR + '/helloworld.eml', tempfilename)
self.tempfiles.append(tempfilename)
self.config.set('ArchivePlugin', 'storeoriginal', '0')
candidate = ArchivePlugin(self.config)
suspect = Suspect(
's[email protected]', '[email protected]', tempfilename)
origmessage = suspect.get_source()
# modify the mesg
msgrep = suspect.get_message_rep()
msgrep['X-Changed-Something'] = 'Yes'
suspect.setMessageRep(msgrep)
filename = candidate.archive(suspect)
self.assertTrue(filename != None and filename)
self.tempfiles.append(filename)
archivedmessage = open(filename, 'r').read()
self.assertNotEqual(origmessage.strip(), archivedmessage.strip(
)), 'Archived message should have stored modified message'