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


Python mail.PixelatedMail类代码示例

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


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

示例1: test_encoding_special_character_on_header

    def test_encoding_special_character_on_header(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=?="

        pixel_mail = PixelatedMail()

        self.assertEqual(pixel_mail._decode_header(subject), 'test encoding St\xc3\xa4ch')
        self.assertEqual(pixel_mail._decode_header(email_from), 'St\xc3\xa4ch <[email protected]>')
        self.assertEqual(pixel_mail._decode_header(email_to), '"\xc3\x84\xc3\xbc\xc3\xb6 \xc3\x96\xc3\xbc\xc3\xa4" <[email protected]>, F\xc3\xb6lker <[email protected]>')
        self.assertEqual(pixel_mail._decode_header(None), None)
开发者ID:EderRoger,项目名称:pixelated-user-agent,代码行数:11,代码来源:test_mail.py

示例2: mail

    def mail(self, ident):
        fdoc = self.get_flags_by_chash(ident)
        hdoc = self.get_header_by_chash(ident)
        bdoc = self.get_content_by_phash(hdoc.content['body'])
        parts = self._extract_parts(hdoc.content)

        return PixelatedMail.from_soledad(fdoc, hdoc, bdoc, parts=parts, soledad_querier=self)
开发者ID:EderRoger,项目名称:pixelated-user-agent,代码行数:7,代码来源:soledad_reader_mixin.py

示例3: 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

示例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_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

示例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_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

示例8: test_broken_content_type_defaults_to_usascii

    def test_broken_content_type_defaults_to_usascii(self):
        plain_headers = {'Content-Type': 'I lie to you', 'Content-Transfer-Encoding': 'quoted-printable'}
        html_headers = {'Content-Type': 'text/html;\ncharset=utf-8', 'Content-Transfer-Encoding': 'quoted-printable'}
        parts = {'alternatives': [{'content': 'H=E4llo', 'headers': plain_headers}, {'content': '<p>H=C3=A4llo</p>', 'headers': html_headers}]}

        mail = PixelatedMail.from_soledad(None, None, self._create_bdoc(raw='some raw body'), parts=parts, soledad_querier=None)

        self.assertEquals(u'H=E4llo', mail.text_plain_body)
开发者ID:EderRoger,项目名称:pixelated-user-agent,代码行数:8,代码来源:test_mail.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: mail

    def mail(self, ident):
        fdoc = yield self.get_flags_by_chash(ident)
        hdoc = yield self.get_header_by_chash(ident)
        bdoc = yield self.get_content_by_phash(hdoc.content["body"])
        parts = yield self._extract_parts(hdoc.content)

        mail = PixelatedMail.from_soledad(fdoc, hdoc, bdoc, parts=parts)
        defer.returnValue(mail)
开发者ID:phazel,项目名称:pixelated-user-agent,代码行数:8,代码来源:soledad_reader_mixin.py

示例11: test_alternatives_body

    def test_alternatives_body(self):
        parts = {'alternatives': [], 'attachments': []}
        parts['alternatives'].append({'content': 'blablabla', 'headers': {'Content-Type': 'text/plain'}})
        parts['alternatives'].append({'content': '<p>blablabla</p>', 'headers': {'Content-Type': 'text/html'}})

        mail = PixelatedMail.from_soledad(None, None, self._create_bdoc(raw='blablabla'), parts=parts, soledad_querier=None)

        self.assertRegexpMatches(mail.html_body, '^<p>blablabla</p>$')
        self.assertRegexpMatches(mail.text_plain_body, '^blablabla$')
开发者ID:EderRoger,项目名称:pixelated-user-agent,代码行数:9,代码来源:test_mail.py

示例12: 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

示例13: 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

示例14: 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

示例15: test_alternatives_body

    def test_alternatives_body(self):
        parts = {"alternatives": [], "attachments": []}
        parts["alternatives"].append({"content": "blablabla", "headers": {"Content-Type": "text/plain"}})
        parts["alternatives"].append({"content": "<p>blablabla</p>", "headers": {"Content-Type": "text/html"}})

        mail = PixelatedMail.from_soledad(None, None, self._create_bdoc(raw="blablabla"), parts=parts)

        self.assertRegexpMatches(mail.html_body, "^<p>blablabla</p>$")
        self.assertRegexpMatches(mail.text_plain_body, "^blablabla$")
开发者ID:phazel,项目名称:pixelated-user-agent,代码行数:9,代码来源:test_mail.py


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