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


Python message.Message类代码示例

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


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

示例1: test_on_new_message_invalidate

 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,代码行数:32,代码来源:_test_caching.py

示例2: test_no_from

 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,代码行数:7,代码来源:test_utils.py

示例3: test_add_in_classical_thread

 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,代码行数:32,代码来源:test_analysis.py

示例4: test_properties_on_new_message

 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,代码行数:26,代码来源:_test_caching.py

示例5: test_sync_mailman_user

 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,代码行数:25,代码来源:_test_caching.py

示例6: test_vote_cancel

 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,代码行数:25,代码来源:test_views.py

示例7: _get_msg

 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,代码行数:7,代码来源:test_archiver.py

示例8: test_on_new_message_userid

 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,代码行数:25,代码来源:_test_caching.py

示例9: test_non_ascii_message

 def test_non_ascii_message(self):
     msg = Message()
     msg['From'] = '[email protected]'
     msg['To'] = '[email protected]'
     msg['Content-Type'] = 'multipart/mixed'
     msg.attach(MIMEText('message with non-ascii chars: \xc3\xa9',
                         'plain', 'utf-8'))
     mbox = digest_mbox(self._mlist)
     mbox_path = os.path.join(self._mlist.data_path, 'digest.mmdf')
     mbox.add(msg.as_string())
     self._digestq.enqueue(
         msg,
         listname=self._mlist.fqdn_listname,
         digest_path=mbox_path,
         volume=1, digest_number=1)
     # Use any error logs as the error message if the test fails.
     error_log = LogFileMark('mailman.error')
     self._runner.run()
     # The runner will send the file to the shunt queue on exception.
     self.assertEqual(len(self._shuntq.files), 0, error_log.read())
     # There are two messages in the virgin queue: the digest as plain-text
     # and as multipart.
     messages = get_queue_messages('virgin')
     self.assertEqual(len(messages), 2)
     self.assertEqual(
         sorted(item.msg.get_content_type() for item in messages),
         ['multipart/mixed', 'text/plain'])
     for item in messages:
         self.assertEqual(item.msg['subject'],
                          'Test Digest, Vol 1, Issue 1')
开发者ID:adam-iris,项目名称:mailman,代码行数:30,代码来源:test_digest.py

示例10: setUp

 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,代码行数:8,代码来源:test_archives.py

示例11: test_multiple_reference

 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,代码行数:8,代码来源:test_utils.py

示例12: test_in_reply_to

 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,代码行数:8,代码来源:test_utils.py

示例13: _create_email

 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,代码行数:9,代码来源:test_sa_model.py

示例14: test_get_sender_name

 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,代码行数:9,代码来源:test_sa_store.py

示例15: test_in_reply_to_and_reference

 def test_in_reply_to_and_reference(self):
     """The In-Reply-To header should win over References"""
     msg = Message()
     msg["From"] = "[email protected]"
     msg["Message-ID"] = "<dummy>"
     msg["In-Reply-To"] = " <ref-1> "
     msg["References"] = " <ref-2> "
     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


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