当前位置: 首页>>代码示例>>Python>>正文


Python Message.replace_header方法代码示例

本文整理汇总了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)
开发者ID:jottinger,项目名称:hyperkitty,代码行数:27,代码来源:test_views.py

示例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)
开发者ID:Psycojoker,项目名称:hyperkitty,代码行数:28,代码来源:_test_caching.py

示例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))
开发者ID:adam-iris,项目名称:kittystore,代码行数:15,代码来源:test_store.py

示例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'
         ]))
开发者ID:Psycojoker,项目名称:hyperkitty,代码行数:21,代码来源:_test_caching.py


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