• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python test_helper.leap_mail函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: test_update_tags_notifies_tag_service

    def test_update_tags_notifies_tag_service(self):
        db_path = '/tmp/test_update_tags_notifies_tag_service'
        TagService.instance = TagService(TagIndex(db_path))

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

        mail.update_tags({'new_tag'})
        self.assertIn(Tag('new_tag'), mail.tag_service.all_tags())

        os.remove(db_path + '.db')
开发者ID:vintrepid,项目名称:pixelated-user-agent,代码行数:10,代码来源:pixelated_mail_test.py


示例17: test_parse_date_from_soledad_fallback_to_received_header_if_date_header_isnt_available

    def test_parse_date_from_soledad_fallback_to_received_header_if_date_header_isnt_available(self):
        leap_mail_date = "Wed, 03 Sep 2014 13:11:15 -0300"
        leap_mail_date_in_iso_format = "2014-09-03T13:11:15-03:00"
        leap_mail_received_header = "by bitmask.local from 127.0.0.1 with ESMTP ;\n " + leap_mail_date

        leap_mail = test_helper.leap_mail(headers={'received': leap_mail_received_header})

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


示例18: test_use_datetime_now_as_fallback_for_invalid_date

    def test_use_datetime_now_as_fallback_for_invalid_date(self):
        leap_mail_date = u'söme däte'
        date_expected = "2014-09-03T13:11:15-03:00"

        when(pixelated.support.date).iso_now().thenReturn(date_expected)
        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']), date_expected)
开发者ID:EderRoger,项目名称:pixelated-user-agent,代码行数:10,代码来源:test_mail.py


示例19: test_fall_back_to_ascii_if_invalid_received_header

    def test_fall_back_to_ascii_if_invalid_received_header(self):
        leap_mail_received_header = u"söme invalid received heäder\n"
        date_expected = "2014-09-03T13:11:15-03:00"

        when(pixelated.support.date).iso_now().thenReturn(date_expected)
        leap_mail = test_helper.leap_mail(headers={'received': leap_mail_received_header})

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

        self.assertEqual(mail.headers['Date'], date_expected)
开发者ID:EderRoger,项目名称:pixelated-user-agent,代码行数:10,代码来源:test_mail.py


示例20: test_parse_UTF8_headers_with_CharsetAscii

    def test_parse_UTF8_headers_with_CharsetAscii(self):
        leap_mail_from = u'"söme ümläuds" <[email protected]>'
        leap_mail_to = u'"söme ümläuds" <[email protected]>,\n"söme ümläuds" <[email protected]>'

        leap_mail = test_helper.leap_mail(extra_headers={'From': leap_mail_from, 'Subject': "some subject", 'To': leap_mail_to})

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

        mail.headers['From'].encode('ascii')
        self.assertEqual(mail.headers['To'], ['"sme mluds" <[email protected]>', '"sme mluds" <[email protected]>'])
开发者ID:EderRoger,项目名称:pixelated-user-agent,代码行数:10,代码来源:test_mail.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python test_helper.request_mock函数代码示例发布时间:2022-05-27
下一篇:
Python script_helper.spawn_python函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap