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


Python test_helper.leap_mail函数代码示例

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


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

示例1: test_index_is_initialized_with_mail_tags_if_empty

    def test_index_is_initialized_with_mail_tags_if_empty(self):
        mail_one = PixelatedMail.from_soledad(*test_helper.leap_mail(uid=0, extra_headers={'X-Tags': '["tag_1"]'}))
        mail_two = PixelatedMail.from_soledad(*test_helper.leap_mail(uid=1, extra_headers={'X-Tags': '["tag_2"]'}))
        mails = [mail_one, mail_two]

        self.tag_service.load_index(mails)

        self.assertEqual(self.tag_service.all_tags(), {Tag('sent'), Tag('inbox'), Tag('drafts'), Tag('trash'), Tag('tag_1'), Tag('tag_2')})
开发者ID:vintrepid,项目名称:pixelated-user-agent,代码行数:8,代码来源:test_tag_service.py

示例2: test_bounced_mails_are_recognized

    def test_bounced_mails_are_recognized(self):
        bounced_mail_hdoc = pkg_resources.resource_filename("test.unit.fixtures", "bounced_mail_hdoc.json")
        with open(bounced_mail_hdoc) as f:
            hdoc = json.loads(f.read())

        bounced_leap_mail = test_helper.leap_mail()
        bounced_leap_mail[1].content = hdoc
        bounced_mail = PixelatedMail.from_soledad(*bounced_leap_mail)

        not_bounced_leap_mail = test_helper.leap_mail()
        not_bounced_mail = PixelatedMail.from_soledad(*not_bounced_leap_mail)

        self.assertTrue(bounced_mail.bounced)
        self.assertIn("[email protected]", bounced_mail.bounced)
        self.assertIn("[email protected] (Mail Delivery System)", bounced_mail.bounced)
        self.assertFalse(not_bounced_mail.bounced)
开发者ID:phazel,项目名称:pixelated-user-agent,代码行数:16,代码来源:test_mail.py

示例3: test_content_type_is_read_from_headers_for_plain_mail_when_converted_to_raw

    def test_content_type_is_read_from_headers_for_plain_mail_when_converted_to_raw(self):
        fdoc, hdoc, bdoc = test_helper.leap_mail(flags=['\\Recent'], body=u'some umlaut \xc3', extra_headers={'Content-Type': 'text/plain; charset=ISO-8859-1'})
        hdoc.content['headers']['Subject'] = 'The subject'
        hdoc.content['headers']['From'] = '[email protected]'
        mail = PixelatedMail.from_soledad(fdoc, hdoc, bdoc, soledad_querier=self.querier)

        mail.raw
开发者ID:fabiopio,项目名称:pixelated-user-agent,代码行数:7,代码来源:mail_test.py

示例4: test_headers_are_encoded_right

    def test_headers_are_encoded_right(self):
        subject = "=?UTF-8?Q?test_encoding_St=C3=A4ch?="
        email_from = "=?UTF-8?Q?St=C3=A4ch_<[email protected]>?="
        email_to = "=?utf-8?b?IsOEw7zDtiDDlsO8w6QiIDxmb2xrZXJAcGl4ZWxhdGVkLXByb2plY3Qub3Jn?=\n =?utf-8?b?PiwgRsO2bGtlciA8Zm9sa2VyQHBpeGVsYXRlZC1wcm9qZWN0Lm9yZz4=?="
        email_cc = "=?UTF-8?Q?St=C3=A4ch_<[email protected]>?="
        email_bcc = "=?UTF-8?Q?St=C3=A4ch_<[email protected]>?="

        leap_mail = test_helper.leap_mail(
            extra_headers={"Subject": subject, "From": email_from, "To": email_to, "Cc": email_cc, "Bcc": email_bcc}
        )

        mail = PixelatedMail.from_soledad(*leap_mail)

        self.assertEqual(str(mail.headers["Subject"]), "test encoding St\xc3\xa4ch")
        self.assertEqual(str(mail.headers["From"]), "St\xc3\xa4ch <[email protected]>")
        self.assertEqual(
            mail.headers["To"],
            [
                '"\xc3\x84\xc3\xbc\xc3\xb6 \xc3\x96\xc3\xbc\xc3\xa4" <[email protected]>',
                "F\xc3\xb6lker <[email protected]>",
            ],
        )
        self.assertEqual(mail.headers["Cc"], ["St\xc3\xa4ch <[email protected]>"])
        self.assertEqual(mail.headers["Bcc"], ["St\xc3\xa4ch <[email protected]>"])

        mail.as_dict()
开发者ID:phazel,项目名称:pixelated-user-agent,代码行数:26,代码来源:test_mail.py

示例5: test_delete_mail

    def test_delete_mail(self):
        mail_to_delete = PixelatedMail.from_soledad(*leap_mail(), soledad_querier=None)
        when(self.mail_service).mail(1).thenReturn(mail_to_delete)

        self.mail_service.delete_mail(1)

        verify(self.mailboxes).move_to_trash(1)
开发者ID:marcwebbie,项目名称:pixelated-user-agent,代码行数:7,代码来源:test_mail_service.py

示例6: test_bounced_mails_are_recognized

    def test_bounced_mails_are_recognized(self):
        bounced_mail_hdoc = os.path.join(os.path.dirname(__file__), '..', 'fixtures', 'bounced_mail_hdoc.json')
        with open(bounced_mail_hdoc) as f:
            hdoc = json.loads(f.read())

        bounced_leap_mail = test_helper.leap_mail()
        bounced_leap_mail[1].content = hdoc
        bounced_mail = PixelatedMail.from_soledad(*bounced_leap_mail, soledad_querier=self.querier)

        not_bounced_leap_mail = test_helper.leap_mail()
        not_bounced_mail = PixelatedMail.from_soledad(*not_bounced_leap_mail, soledad_querier=self.querier)

        self.assertTrue(bounced_mail.bounced)
        self.assertIn('[email protected]', bounced_mail.bounced)
        self.assertIn("[email protected] (Mail Delivery System)", bounced_mail.bounced)
        self.assertFalse(not_bounced_mail.bounced)
开发者ID:EderRoger,项目名称:pixelated-user-agent,代码行数:16,代码来源:test_mail.py

示例7: test_remove_message_from_mailbox

    def test_remove_message_from_mailbox(self):
        mail = PixelatedMail.from_soledad(*test_helper.leap_mail(), soledad_querier=self.querier)
        when(self.querier).mail(1).thenReturn(mail)

        self.mailbox.remove(1)

        verify(self.querier).remove_mail(mail)
开发者ID:kalfonso,项目名称:pixelated-user-agent,代码行数:7,代码来源:test_mailbox.py

示例8: test_as_dict

    def test_as_dict(self):
        headers = {'Subject': 'The subject',
                   'From': '[email protected]',
                   'To': '[email protected]'}
        fdoc, hdoc, bdoc = test_helper.leap_mail(flags=['\\Recent'],
                                                 extra_headers=headers)

        InputMail.FROM_EMAIL_ADDRESS = '[email protected]'

        mail = PixelatedMail.from_soledad(fdoc, hdoc, bdoc, soledad_querier=self.querier)

        _dict = mail.as_dict()

        self.assertEquals(_dict, {'body': 'body',
                                  'header': {
                                      'date': dateparser.parse(hdoc.content['date']).isoformat(),
                                      'from': '[email protected]',
                                      'subject': 'The subject',
                                      'to': ['[email protected]'],
                                      'cc': [],
                                      'bcc': []
                                  },
                                  'ident': 'chash',
                                  'mailbox': 'inbox',
                                  'security_casing': {'imprints': [], 'locks': []},
                                  'status': ['recent'],
                                  'tags': [],
                                  'attachments': [],
                                  'replying': {
                                      'single': '[email protected]',
                                      'all': {
                                          'to-field': ['[email protected]'],
                                          'cc-field': []
                                      }
                                  }})
开发者ID:fabiopio,项目名称:pixelated-user-agent,代码行数:35,代码来源:mail_test.py

示例9: test_recover_mail

    def test_recover_mail(self):
        mail_to_recover = PixelatedMail.from_soledad(*leap_mail(), soledad_querier=None)
        when(self.mail_service).mail(1).thenReturn(mail_to_recover)
        when(self.mail_store).move_mail_to_mailbox(1, 'INBOX').thenReturn(mail_to_recover)

        yield self.mail_service.recover_mail(1)

        verify(self.mail_store).move_mail_to_mailbox(1, 'INBOX')
开发者ID:torquemad,项目名称:pixelated-user-agent,代码行数:8,代码来源:test_mail_service.py

示例10: test_move_to_inbox

    def test_move_to_inbox(self):
        mail = PixelatedMail.from_soledad(*test_helper.leap_mail(), soledad_querier=self.querier)
        when(self.querier).mail(1).thenReturn(mail)
        when(mail).save().thenReturn(None)

        mail.set_mailbox('TRASH')
        recovered_mail = yield self.mailboxes.move_to_inbox(1)
        self.assertEquals('INBOX', recovered_mail.mailbox_name)
        verify(mail).save()
开发者ID:kalfonso,项目名称:pixelated-user-agent,代码行数:9,代码来源:test_mailboxes.py

示例11: test_recover_mail

    def test_recover_mail(self):
        mail_to_recover = PixelatedMail.from_soledad(*leap_mail(), soledad_querier=None)
        when(self.mail_service).mail(1).thenReturn(mail_to_recover)
        when(self.mailboxes).move_to_inbox(1).thenReturn(mail_to_recover)

        self.mail_service.recover_mail(1)

        verify(self.mailboxes).move_to_inbox(1)
        verify(self.search_engine).index_mail(mail_to_recover)
开发者ID:kalfonso,项目名称:pixelated-user-agent,代码行数:9,代码来源:test_mail_service.py

示例12: test_parse_date_from_soledad_uses_date_header_if_available

    def test_parse_date_from_soledad_uses_date_header_if_available(self):
        leap_mail_date = "Wed, 3 Sep 2014 12:36:17 -0300"
        leap_mail_date_in_iso_format = "2014-09-03T12:36:17-03:00"

        leap_mail = test_helper.leap_mail(headers={"date": leap_mail_date})

        mail = PixelatedMail.from_soledad(*leap_mail)

        self.assertEqual(str(mail.headers["Date"]), leap_mail_date_in_iso_format)
开发者ID:phazel,项目名称:pixelated-user-agent,代码行数:9,代码来源:test_mail.py

示例13: test_parse_date_from_soledad_uses_date_header_if_available

    def test_parse_date_from_soledad_uses_date_header_if_available(self):
        leap_mail_date = 'Wed, 3 Sep 2014 12:36:17 -0300'
        leap_mail_date_in_iso_format = "2014-09-03T12:36:17-03:00"

        leap_mail = test_helper.leap_mail(headers={'date': leap_mail_date})

        mail = PixelatedMail.from_soledad(*leap_mail, soledad_querier=self.querier)

        self.assertEqual(str(mail.headers['Date']), leap_mail_date_in_iso_format)
开发者ID:Nangal,项目名称:pixelated-user-agent,代码行数:9,代码来源:mail_test.py

示例14: test_that_body_understands_8bit

    def test_that_body_understands_8bit(self):
        body = u"testtext"
        encoded_body = body

        fdoc, hdoc, bdoc = test_helper.leap_mail()
        parts = {"alternatives": []}
        parts["alternatives"].append({"content": encoded_body, "headers": {"Content-Transfer-Encoding": "8bit"}})
        mail = PixelatedMail.from_soledad(fdoc, hdoc, bdoc, parts=parts)

        self.assertEquals(body, mail.text_plain_body)
开发者ID:phazel,项目名称:pixelated-user-agent,代码行数:10,代码来源:test_mail.py

示例15: test_that_body_understands_base64

    def test_that_body_understands_base64(self):
        body = u"bl\xe1"
        encoded_body = unicode(body.encode("utf-8").encode("base64"))

        fdoc, hdoc, bdoc = test_helper.leap_mail()
        parts = {"alternatives": []}
        parts["alternatives"].append({"content": encoded_body, "headers": {"Content-Transfer-Encoding": "base64"}})
        mail = PixelatedMail.from_soledad(fdoc, hdoc, bdoc, parts=parts)

        self.assertEquals(body, mail.text_plain_body)
开发者ID:phazel,项目名称:pixelated-user-agent,代码行数:10,代码来源:test_mail.py


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