本文整理汇总了Python中pixelated.adapter.model.mail.PixelatedMail.from_soledad方法的典型用法代码示例。如果您正苦于以下问题:Python PixelatedMail.from_soledad方法的具体用法?Python PixelatedMail.from_soledad怎么用?Python PixelatedMail.from_soledad使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pixelated.adapter.model.mail.PixelatedMail
的用法示例。
在下文中一共展示了PixelatedMail.from_soledad方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_bounced_mails_are_recognized
# 需要导入模块: from pixelated.adapter.model.mail import PixelatedMail [as 别名]
# 或者: from pixelated.adapter.model.mail.PixelatedMail import from_soledad [as 别名]
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)
示例2: test_headers_are_encoded_right
# 需要导入模块: from pixelated.adapter.model.mail import PixelatedMail [as 别名]
# 或者: from pixelated.adapter.model.mail.PixelatedMail import from_soledad [as 别名]
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()
示例3: mail
# 需要导入模块: from pixelated.adapter.model.mail import PixelatedMail [as 别名]
# 或者: from pixelated.adapter.model.mail.PixelatedMail import from_soledad [as 别名]
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)
示例4: test_remove_message_from_mailbox
# 需要导入模块: from pixelated.adapter.model.mail import PixelatedMail [as 别名]
# 或者: from pixelated.adapter.model.mail.PixelatedMail import from_soledad [as 别名]
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)
示例5: test_bounced_mails_are_recognized
# 需要导入模块: from pixelated.adapter.model.mail import PixelatedMail [as 别名]
# 或者: from pixelated.adapter.model.mail.PixelatedMail import from_soledad [as 别名]
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)
示例6: test_delete_mail
# 需要导入模块: from pixelated.adapter.model.mail import PixelatedMail [as 别名]
# 或者: from pixelated.adapter.model.mail.PixelatedMail import from_soledad [as 别名]
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)
示例7: test_broken_content_type_defaults_to_usascii
# 需要导入模块: from pixelated.adapter.model.mail import PixelatedMail [as 别名]
# 或者: from pixelated.adapter.model.mail.PixelatedMail import from_soledad [as 别名]
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)
示例8: test_recover_mail
# 需要导入模块: from pixelated.adapter.model.mail import PixelatedMail [as 别名]
# 或者: from pixelated.adapter.model.mail.PixelatedMail import from_soledad [as 别名]
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')
示例9: mail
# 需要导入模块: from pixelated.adapter.model.mail import PixelatedMail [as 别名]
# 或者: from pixelated.adapter.model.mail.PixelatedMail import from_soledad [as 别名]
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)
示例10: test_parse_date_from_soledad_uses_date_header_if_available
# 需要导入模块: from pixelated.adapter.model.mail import PixelatedMail [as 别名]
# 或者: from pixelated.adapter.model.mail.PixelatedMail import from_soledad [as 别名]
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)
示例11: test_alternatives_body
# 需要导入模块: from pixelated.adapter.model.mail import PixelatedMail [as 别名]
# 或者: from pixelated.adapter.model.mail.PixelatedMail import from_soledad [as 别名]
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$")
示例12: test_move_to_inbox
# 需要导入模块: from pixelated.adapter.model.mail import PixelatedMail [as 别名]
# 或者: from pixelated.adapter.model.mail.PixelatedMail import from_soledad [as 别名]
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()
示例13: test_alternatives_body
# 需要导入模块: from pixelated.adapter.model.mail import PixelatedMail [as 别名]
# 或者: from pixelated.adapter.model.mail.PixelatedMail import from_soledad [as 别名]
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$')
示例14: test_percent_character_is_allowed_on_body
# 需要导入模块: from pixelated.adapter.model.mail import PixelatedMail [as 别名]
# 或者: from pixelated.adapter.model.mail.PixelatedMail import from_soledad [as 别名]
def test_percent_character_is_allowed_on_body(self):
parts = {'alternatives': [], 'attachments': []}
parts['alternatives'].append({'content': '100% happy with percentage symbol', 'headers': {'Content-Type': 'text/plain'}})
parts['alternatives'].append({'content': '<p>100% happy with percentage symbol</p>', 'headers': {'Content-Type': 'text/html'}})
mail = PixelatedMail.from_soledad(None, None, self._create_bdoc(raw="100% happy with percentage symbol"), parts=parts, soledad_querier=None)
self.assertRegexpMatches(mail.text_plain_body, '([\s\S]*100%)')
self.assertRegexpMatches(mail.html_body, '([\s\S]*100%)')
示例15: test_parse_date_from_soledad_uses_date_header_if_available
# 需要导入模块: from pixelated.adapter.model.mail import PixelatedMail [as 别名]
# 或者: from pixelated.adapter.model.mail.PixelatedMail import from_soledad [as 别名]
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)