本文整理汇总了Python中mailman.email.message.Message.replace_header方法的典型用法代码示例。如果您正苦于以下问题:Python Message.replace_header方法的具体用法?Python Message.replace_header怎么用?Python Message.replace_header使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mailman.email.message.Message
的用法示例。
在下文中一共展示了Message.replace_header方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_vote_cancel
# 需要导入模块: from mailman.email.message import Message [as 别名]
# 或者: from mailman.email.message.Message import replace_header [as 别名]
def test_vote_cancel(self):
ml = FakeList("[email protected]")
msg = Message()
msg["From"] = "[email protected]"
msg["Message-ID"] = "<msg1>"
msg.set_payload("Dummy message")
self.store.add_to_list(ml, msg)
msg.replace_header("Message-ID", "<msg2>")
self.store.add_to_list(ml, msg)
msg1 = self.store.get_message_by_id_from_list("[email protected]", "msg1")
msg1.vote(1, u"testuser")
msg2 = self.store.get_message_by_id_from_list("[email protected]", "msg2")
msg2.vote(-1, u"testuser")
self.assertEqual(msg1.likes, 1)
self.assertEqual(msg2.dislikes, 1)
for msg in (msg1, msg2):
url = reverse('message_vote', args=("[email protected]",
msg.message_id_hash))
resp = self.client.post(url, {"vote": "0"})
self.assertEqual(resp.status_code, 200)
self.assertEqual(msg.likes, 0)
self.assertEqual(msg.dislikes, 0)
result = json.loads(resp.content)
self.assertEqual(result["like"], 0)
self.assertEqual(result["dislike"], 0)
示例2: test_properties_on_new_message
# 需要导入模块: from mailman.email.message import Message [as 别名]
# 或者: from mailman.email.message.Message import replace_header [as 别名]
def test_properties_on_new_message(self):
ml = FakeList("example-list")
ml.display_name = u"name 1"
ml.subject_prefix = u"[prefix 1]"
ml.description = u"desc 1"
kittystore.utils.MM_CLIENT.get_list.side_effect = lambda n: ml
msg = Message()
msg["From"] = "[email protected]"
msg["Message-ID"] = "<dummy>"
msg.set_payload("Dummy message")
self.store.add_to_list("example-list", msg)
ml_db = self.store.get_lists()[0]
self.assertEqual(ml_db.display_name, "name 1")
self.assertEqual(ml_db.subject_prefix, "[prefix 1]")
ml.display_name = u"name 2"
ml.subject_prefix = u"[prefix 2]"
ml.description = u"desc 2"
ml.archive_policy = "private"
msg.replace_header("Message-ID", "<dummy2>")
self.store.add_to_list("example-list", msg)
ml_db = self.store.get_lists()[0]
#ml_db = self.store.db.find(List).one()
self.assertEqual(ml_db.display_name, "name 2")
self.assertEqual(ml_db.subject_prefix, "[prefix 2]")
self.assertEqual(ml_db.description, "desc 2")
self.assertEqual(ml_db.archive_policy, ArchivePolicy.private)
示例3: test_duplicate_nonascii
# 需要导入模块: from mailman.email.message import Message [as 别名]
# 或者: from mailman.email.message.Message import replace_header [as 别名]
def test_duplicate_nonascii(self):
msg = Message()
msg["From"] = b"[email protected]"
msg["Message-ID"] = "<dummy>"
msg.set_payload("Dummy message")
self.store.add_to_list(FakeList("example-list"), msg)
self.assertEqual(self.store.get_list_size("example-list"), 1)
self.assertTrue(self.store.is_message_in_list("example-list", "dummy"))
msg.replace_header("From", b"dummy-non-ascii\xc3\[email protected]")
try:
self.store.add_to_list(FakeList("example-list"), msg)
except UnicodeDecodeError, e:
self.fail("Died on a non-ascii header message: %s" % unicode(e))
示例4: test_on_new_thread_invalidate
# 需要导入模块: from mailman.email.message import Message [as 别名]
# 或者: from mailman.email.message.Message import replace_header [as 别名]
def test_on_new_thread_invalidate(self):
# Check that the cache is invalidated on new message
msg = Message()
msg["From"] = "[email protected]"
msg["Message-ID"] = "<dummy>"
msg.set_payload("Dummy message")
self.store.add_to_list("example-list", msg)
msg.replace_header("Message-ID", "<dummy2>")
msg["In-Reply-To"] = "<dummy>"
self.store.add_to_list("example-list", msg)
call_args = [ call[0][0] for call in self.store.db.cache.set.call_args_list ]
# we have duplicates because both the Storm and the SQLAlchemy model
# subscribe to the event, so we must deduplicate
call_args = set(call_args)
#from pprint import pprint; pprint(call_args)
#print(repr(call_args))
self.assertEqual(call_args, set([
u'list:example-list:thread:QKODQBCADMDSP5YPOPKECXQWEQAMXZL3:subject'
]))