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


Python Message.set_payload方法代码示例

本文整理汇总了Python中mailman.email.message.Message.set_payload方法的典型用法代码示例。如果您正苦于以下问题:Python Message.set_payload方法的具体用法?Python Message.set_payload怎么用?Python Message.set_payload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mailman.email.message.Message的用法示例。


在下文中一共展示了Message.set_payload方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_sync_mailman_user

# 需要导入模块: from mailman.email.message import Message [as 别名]
# 或者: from mailman.email.message.Message import set_payload [as 别名]
 def test_sync_mailman_user(self):
     # Check that the user_id is set when sync_mailman_user is run
     msg = Message()
     msg["From"] = "[email protected]"
     msg["Message-ID"] = "<dummy>"
     msg.set_payload("Dummy message")
     self.store.add_to_list("example-list", msg)
     dbmsg = self.store.get_message_by_id_from_list(
             "example-list", "dummy")
     self.assertEqual(dbmsg.sender.user_id, None)
     # setup Mailman's reply
     uid = uuid.uuid1()
     new_user_id = FakeMMUser()
     new_user_id.user_id = uid.int
     self.mm_client.get_user.side_effect = lambda addr: new_user_id
     # do the test and check
     mailman_user.sync_mailman_user(self.store)
     #dbmsg = self.store.get_message_by_id_from_list(
     #        "example-list", "dummy")
     self.assertEqual(dbmsg.sender.user_id, uid)
     self.assertTrue(dbmsg.sender.user is not None,
             "A 'User' instance was not created")
     self.assertEqual(dbmsg.sender.user.id, uid)
     self.assertEqual(1,
             self.store.get_message_count_by_user_id(uid))
开发者ID:Psycojoker,项目名称:hyperkitty,代码行数:27,代码来源:_test_caching.py

示例2: test_no_from

# 需要导入模块: from mailman.email.message import Message [as 别名]
# 或者: from mailman.email.message.Message import set_payload [as 别名]
 def test_no_from(self):
     msg = Message()
     msg.set_payload("Dummy message")
     try:
         name, email = kittystore.utils.parseaddr(msg["From"])
     except AttributeError, e:
         self.fail(e)
开发者ID:adam-iris,项目名称:kittystore,代码行数:9,代码来源:test_utils.py

示例3: setUp

# 需要导入模块: from mailman.email.message import Message [as 别名]
# 或者: from mailman.email.message.Message import set_payload [as 别名]
 def setUp(self):
     self.user = User.objects.create_user('testuser', '[email protected]', 'testPass')
     self.client.login(username='testuser', password='testPass')
     # Create test data
     ml = FakeList("[email protected]")
     ml.subject_prefix = u"[example] "
     # Create 3 threads
     messages = []
     for msgnum in range(3):
         msg = Message()
         msg["From"] = "[email protected]"
         msg["Message-ID"] = "<id%d>" % (msgnum+1)
         msg["Subject"] = "Dummy message"
         msg.set_payload("Dummy message")
         self.store.add_to_list(ml, msg)
         messages.append(msg)
     # 1st is unread, 2nd is read, 3rd is updated
     LastView.objects.create(list_address="[email protected]", user=self.user,
                             threadid=get_message_id_hash("<id2>"))
     LastView.objects.create(list_address="[email protected]", user=self.user,
                             threadid=get_message_id_hash("<id3>"))
     msg4 = Message()
     msg4["From"] = "[email protected]"
     msg4["Message-ID"] = "<id4>"
     msg4["Subject"] = "Dummy message"
     msg4["In-Reply-To"] = "<id3>"
     msg4.set_payload("Dummy message")
     self.store.add_to_list(ml, msg4)
开发者ID:liam-middlebrook,项目名称:hyperkitty,代码行数:30,代码来源:test_accounts.py

示例4: test_add_in_classical_thread

# 需要导入模块: from mailman.email.message import Message [as 别名]
# 或者: from mailman.email.message.Message import set_payload [as 别名]
 def test_add_in_classical_thread(self):
     # msg1
     # |-msg2
     # | `-msg4
     # `-msg3
     ml = FakeList("example-list")
     msgs = []
     for num in range(1, 5):
         msg = Message()
         msg["From"] = "sender%[email protected]" % num
         msg["Message-ID"] = "<msg%d>" % num
         msg.set_payload("message %d" % num)
         msgs.append(msg)
     msgs[1]["In-Reply-To"] = "<msg1>"
     msgs[2]["In-Reply-To"] = "<msg1>"
     msgs[3]["In-Reply-To"] = "<msg2>"
     for msg in msgs:
         self.store.add_to_list(ml, msg)
     msgs = []
     for num in range(1, 5):
         msg = self.store.get_message_by_id_from_list(
                 "example-list", "msg%d" % num)
         msgs.append(msg)
     msg1, msg2, msg3, msg4 = msgs
     self.assertEqual(msg1.thread_order, 0)
     self.assertEqual(msg1.thread_depth, 0)
     self.assertEqual(msg2.thread_order, 1)
     self.assertEqual(msg2.thread_depth, 1)
     self.assertEqual(msg3.thread_order, 3)
     self.assertEqual(msg3.thread_depth, 1)
     self.assertEqual(msg4.thread_order, 2)
     self.assertEqual(msg4.thread_depth, 2)
开发者ID:adam-iris,项目名称:kittystore,代码行数:34,代码来源:test_analysis.py

示例5: test_on_new_message_invalidate

# 需要导入模块: from mailman.email.message import Message [as 别名]
# 或者: from mailman.email.message.Message import set_payload [as 别名]
 def test_on_new_message_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")
     today = datetime.datetime.utcnow().date() # don't use datetime.date.today(), we need UTC
     self.store.add_to_list("example-list", msg)
     # calls to cache.delete() -- invalidation
     delete_args = [ call[0][0] for call in
                     self.store.db.cache.delete.call_args_list ]
     #from pprint import pprint; pprint(delete_args)
     self.assertEqual(set(delete_args), set([
         u'list:example-list:recent_participants_count',
         u'list:example-list:recent_threads_count',
         u'list:example-list:participants_count:%d:%d' % (today.year, today.month),
         u'list:example-list:thread:QKODQBCADMDSP5YPOPKECXQWEQAMXZL3:emails_count',
         u'list:example-list:thread:QKODQBCADMDSP5YPOPKECXQWEQAMXZL3:participants_count'
         ]))
     # calls to cache.get_or_create() -- repopulation
     goc_args = [ call[0][0] for call in
                  self.store.db.cache.get_or_create.call_args_list ]
     #from pprint import pprint; pprint(goc_args)
     self.assertEqual(set(goc_args), set([
         u'list:example-list:recent_participants_count',
         u'list:example-list:recent_threads_count',
         u'list:example-list:participants_count:%d:%d' % (today.year, today.month),
         u'list:example-list:threads_count:%d:%d' % (today.year, today.month),
         u'list:example-list:thread:QKODQBCADMDSP5YPOPKECXQWEQAMXZL3:emails_count',
         u'list:example-list:thread:QKODQBCADMDSP5YPOPKECXQWEQAMXZL3:participants_count',
         u'list:example-list:thread:QKODQBCADMDSP5YPOPKECXQWEQAMXZL3:starting_email_id',
         ]))
开发者ID:Psycojoker,项目名称:hyperkitty,代码行数:34,代码来源:_test_caching.py

示例6: test_vote_cancel

# 需要导入模块: from mailman.email.message import Message [as 别名]
# 或者: from mailman.email.message.Message import set_payload [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

示例7: test_properties_on_new_message

# 需要导入模块: from mailman.email.message import Message [as 别名]
# 或者: from mailman.email.message.Message import set_payload [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

示例8: _get_msg

# 需要导入模块: from mailman.email.message import Message [as 别名]
# 或者: from mailman.email.message.Message import set_payload [as 别名]
 def _get_msg(self):
     msg = Message()
     msg["From"] = "[email protected]"
     msg["Message-ID"] = "<dummy>"
     msg["Message-ID-Hash"] = "QKODQBCADMDSP5YPOPKECXQWEQAMXZL3"
     msg.set_payload("Dummy message")
     return msg
开发者ID:1234-,项目名称:mailman-hyperkitty,代码行数:9,代码来源:test_archiver.py

示例9: setUp

# 需要导入模块: from mailman.email.message import Message [as 别名]
# 或者: from mailman.email.message.Message import set_payload [as 别名]
 def setUp(self):
     self.user = User.objects.create_user('testuser', '[email protected]', 'testPass')
     self.client.login(username='testuser', password='testPass')
     store = kittystore.get_store(SettingsModule(), debug=False, auto_create=True)
     self.client.defaults = {"kittystore.store": store,
                             "HTTP_USER_AGENT": "testbot",
                             }
     # Create test data
     ml = FakeList("[email protected]")
     ml.subject_prefix = u"[example] "
     # Create 3 threads
     messages = []
     for msgnum in range(3):
         msg = Message()
         msg["From"] = "[email protected]"
         msg["Message-ID"] = "<id%d>" % (msgnum+1)
         msg["Subject"] = "Dummy message"
         msg.set_payload("Dummy message")
         store.add_to_list(ml, msg)
         messages.append(msg)
     # 1st is unread, 2nd is read, 3rd is updated
     LastView.objects.create(list_address="[email protected]", user=self.user,
                             threadid=get_message_id_hash("<id2>"))
     LastView.objects.create(list_address="[email protected]", user=self.user,
                             threadid=get_message_id_hash("<id3>"))
     msg4 = Message()
     msg4["From"] = "[email protected]"
     msg4["Message-ID"] = "<id4>"
     msg4["Subject"] = "Dummy message"
     msg4["In-Reply-To"] = "<id3>"
     msg4.set_payload("Dummy message")
     store.add_to_list(ml, msg4)
开发者ID:jottinger,项目名称:hyperkitty,代码行数:34,代码来源:test_views.py

示例10: test_on_new_message_userid

# 需要导入模块: from mailman.email.message import Message [as 别名]
# 或者: from mailman.email.message.Message import set_payload [as 别名]
 def test_on_new_message_userid(self):
     # Check that the user_id is set on a new message
     msg = Message()
     msg["From"] = "[email protected]"
     msg["Message-ID"] = "<dummy>"
     msg.set_payload("Dummy message")
     # setup Mailman's reply
     new_user_id = FakeMMUser()
     uid = uuid.uuid1()
     new_user_id.user_id = uid.int
     self.mm_client.get_user.side_effect = lambda addr: new_user_id
     # check the User does not exist yet
     self.assertEqual(0,
             self.store.get_message_count_by_user_id(uid))
     # do the test and check
     self.store.add_to_list("example-list", msg)
     dbmsg = self.store.get_message_by_id_from_list(
             "example-list", "dummy")
     self.assertEqual(dbmsg.sender.user_id, uid)
     self.assertTrue(dbmsg.sender.user is not None,
             "A 'User' instance was not created")
     self.assertEqual(dbmsg.sender.user.id, uid)
     self.assertEqual(1,
             self.store.get_message_count_by_user_id(uid))
     self.assertEqual(self.store.get_users_count(), 1)
开发者ID:Psycojoker,项目名称:hyperkitty,代码行数:27,代码来源:_test_caching.py

示例11: test_multiple_reference

# 需要导入模块: from mailman.email.message import Message [as 别名]
# 或者: from mailman.email.message.Message import set_payload [as 别名]
 def test_multiple_reference(self):
     msg = Message()
     msg["From"] = "[email protected]"
     msg["Message-ID"] = "<dummy>"
     msg["References"] = " <ref-1> <ref-2> "
     msg.set_payload("Dummy message")
     ref_id = kittystore.utils.get_ref(msg)
     self.assertEqual(ref_id, "ref-2")
开发者ID:adam-iris,项目名称:kittystore,代码行数:10,代码来源:test_utils.py

示例12: setUp

# 需要导入模块: from mailman.email.message import Message [as 别名]
# 或者: from mailman.email.message.Message import set_payload [as 别名]
 def setUp(self):
     # Create the list by adding a dummy message
     ml = FakeList("[email protected]")
     msg = Message()
     msg["From"] = "[email protected]"
     msg["Message-ID"] = "<msg>"
     msg.set_payload("Dummy message")
     self.store.add_to_list(ml, msg)
开发者ID:Yomi0,项目名称:hyperkitty,代码行数:10,代码来源:test_archives.py

示例13: test_in_reply_to

# 需要导入模块: from mailman.email.message import Message [as 别名]
# 或者: from mailman.email.message.Message import set_payload [as 别名]
 def test_in_reply_to(self):
     msg = Message()
     msg["From"] = "[email protected]"
     msg["Message-ID"] = "<dummy>"
     msg["In-Reply-To"] = " <ref-1> "
     msg.set_payload("Dummy message")
     ref_id = kittystore.utils.get_ref(msg)
     self.assertEqual(ref_id, "ref-1")
开发者ID:adam-iris,项目名称:kittystore,代码行数:10,代码来源:test_utils.py

示例14: test_get_sender_name

# 需要导入模块: from mailman.email.message import Message [as 别名]
# 或者: from mailman.email.message.Message import set_payload [as 别名]
 def test_get_sender_name(self):
     msg = Message()
     msg["From"] = "Sender Name <[email protected]>"
     msg["Message-ID"] = "<dummy>"
     msg.set_payload("Dummy message")
     self.store.add_to_list(FakeList("example-list"), msg)
     stored_msg = self.store.db.query(Email).one()
     user_id = stored_msg.sender.user_id
     self.assertEqual(self.store.get_sender_name(user_id), "Sender Name")
开发者ID:adam-iris,项目名称:kittystore,代码行数:11,代码来源:test_sa_store.py

示例15: _create_email

# 需要导入模块: from mailman.email.message import Message [as 别名]
# 或者: from mailman.email.message.Message import set_payload [as 别名]
 def _create_email(self, num, reply_to=None):
     ml = FakeList("example-list")
     msg = Message()
     msg["From"] = "sender%[email protected]" % num
     msg["Message-ID"] = "<msg%d>" % num
     msg.set_payload("message %d" % num)
     if reply_to is not None:
         msg["In-Reply-To"] = "<msg%d>" % reply_to
     self.store.add_to_list(ml, msg)
开发者ID:adam-iris,项目名称:kittystore,代码行数:11,代码来源:test_sa_model.py


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