本文整理汇总了Python中pixelated.adapter.model.mail.InputMail类的典型用法代码示例。如果您正苦于以下问题:Python InputMail类的具体用法?Python InputMail怎么用?Python InputMail使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了InputMail类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_for_save_adds_from
def test_get_for_save_adds_from(self):
InputMail.FROM_EMAIL_ADDRESS = "[email protected]"
headers = {"Subject": "The subject", "Date": str(datetime.now()), "To": "[email protected]"}
input_mail = InputMail()
input_mail.headers = headers
self.assertEqual("[email protected]", input_mail.get_for_save(1, "SENT")[1][HEADERS_KEY]["From"])
示例2: test_get_for_save_adds_from
def test_get_for_save_adds_from(self):
InputMail.FROM_EMAIL_ADDRESS = '[email protected]'
headers = {'Subject': 'The subject',
'Date': str(datetime.now()),
'To': '[email protected]'}
input_mail = InputMail()
input_mail.headers = headers
self.assertEqual('[email protected]', input_mail.get_for_save(1, 'SENT')[1][fields.HEADERS_KEY]['From'])
示例3: test_charset_latin1
def test_charset_latin1(self):
mail_file = pkg_resources.resource_filename('test.unit.fixtures', 'mail.latin1')
with open(mail_file) as latin1_mail:
mail = message_from_file(latin1_mail)
input_mail = InputMail.from_python_mail(mail)
body = u'latin1 é çñ\n'
self.assertEqual(body, input_mail.body)
示例4: send_mail
def send_mail(self, content_dict):
mail = InputMail.from_dict(content_dict, self.account_email)
draft_id = content_dict.get('ident')
yield self.mail_sender.sendmail(mail)
sent_mail = yield self.move_to_sent(draft_id, mail)
defer.returnValue(sent_mail)
示例5: render_PUT
def render_PUT(self, request):
content_dict = json.loads(request.content.read())
_mail = InputMail.from_dict(content_dict)
draft_id = content_dict.get("ident")
def defer_response(deferred):
deferred.addCallback(lambda pixelated_mail: respond_json_deferred({"ident": pixelated_mail.ident}, request))
if draft_id:
deferred_check = self._mail_service.mail_exists(draft_id)
def handleDuplicatedDraftException(error):
respond_json_deferred("", request, status_code=422)
def return422otherwise(mail_exists):
if not mail_exists:
respond_json_deferred("", request, status_code=422)
else:
new_draft = self._draft_service.update_draft(draft_id, _mail)
new_draft.addErrback(handleDuplicatedDraftException)
defer_response(new_draft)
deferred_check.addCallback(return422otherwise)
else:
defer_response(self._draft_service.create_draft(_mail))
return server.NOT_DONE_YET
示例6: test_charset_utf8
def test_charset_utf8(self):
mail_file = pkg_resources.resource_filename('test.unit.fixtures', 'mail.utf8')
with open(mail_file) as utf8_mail:
mail = message_from_file(utf8_mail)
input_mail = InputMail.from_python_mail(mail)
body = u'utf8 é çñ\n'
self.assertEqual(body, input_mail.body)
示例7: test_if_deduplicates_when_recipient_repeated_in_field
def test_if_deduplicates_when_recipient_repeated_in_field(self):
mail = InputMail.from_dict(duplicates_in_fields_mail_dict(), from_address='[email protected]')
yield self.mail_service._deduplicate_recipients(mail)
self.assertItemsEqual(['[email protected]', '[email protected]'], mail.bcc)
self.assertItemsEqual(['[email protected]', '[email protected]'], mail.to)
self.assertItemsEqual(['[email protected]'], mail.cc)
示例8: test_update_draft
def test_update_draft(self):
mail = InputMail.from_dict(test_helper.mail_dict())
when(self.mail_store).add_mail("DRAFTS", mail.raw).thenReturn(defer.succeed(LeapMail("id", "DRAFTS")))
self.draft_service.update_draft(mail.ident, mail)
inorder.verify(self.mail_store).add_mail("DRAFTS", mail.raw)
inorder.verify(self.mail_store).delete_mail(mail.ident)
示例9: add_welcome_mail
def add_welcome_mail(mail_store):
welcome_mail = pkg_resources.resource_filename('pixelated.assets', 'welcome.mail')
with open(welcome_mail) as mail_template_file:
mail_template = message_from_file(mail_template_file)
input_mail = InputMail.from_python_mail(mail_template)
mail_store.add_mail('INBOX', input_mail.raw)
示例10: test_to_mime_multipart_handles_alternative_bodies
def test_to_mime_multipart_handles_alternative_bodies(self):
mime_multipart = InputMail.from_dict(multipart_mail_dict()).to_mime_multipart()
part_one = 'Content-Type: text/plain; charset="us-ascii"\nMIME-Version: 1.0\nContent-Transfer-Encoding: 7bit\n\nHello world!'
part_two = 'Content-Type: text/html; charset="us-ascii"\nMIME-Version: 1.0\nContent-Transfer-Encoding: 7bit\n\n<p>Hello html world!</p>'
self.assertRegexpMatches(mime_multipart.as_string(), part_one)
self.assertRegexpMatches(mime_multipart.as_string(), part_two)
示例11: test_update_draft
def test_update_draft(self):
mail = InputMail.from_dict(test_helper.mail_dict())
when(self.drafts_mailbox).add(mail).thenReturn(mail)
self.draft_service.update_draft(mail.ident, mail)
inorder.verify(self.drafts_mailbox).add(mail)
inorder.verify(self.drafts_mailbox).remove(mail.ident)
示例12: test_if_recipient_doubled_in_fields_send_only_in_bcc
def test_if_recipient_doubled_in_fields_send_only_in_bcc(self):
mail = InputMail.from_dict(duplicates_in_fields_mail_dict(), from_address='[email protected]')
yield self.mail_service._deduplicate_recipients(mail)
self.assertIn('[email protected]', mail.to)
self.assertNotIn('[email protected]', mail.to)
self.assertIn('[email protected]', mail.bcc)
示例13: add_welcome_mail
def add_welcome_mail(mail_store):
current_path = os.path.dirname(os.path.abspath(__file__))
welcome_mail = os.path.join(current_path, "assets", "welcome.mail")
with open(welcome_mail) as mail_template_file:
mail_template = message_from_file(mail_template_file)
input_mail = InputMail.from_python_mail(mail_template)
mail_store.add_mail("INBOX", input_mail.raw)
示例14: test_single_recipient
def test_single_recipient(self):
mail_single_recipient = {
"body": "",
"header": {"to": ["[email protected]"], "cc": [""], "bcc": [""], "subject": "Oi"},
}
result = InputMail.from_dict(mail_single_recipient).raw
self.assertRegexpMatches(result, "To: [email protected]")
示例15: test_update_draft
def test_update_draft(self):
mail = InputMail.from_dict(test_helper.mail_dict(), from_address='[email protected]')
when(self.mail_store).delete_mail(mail.ident).thenReturn(defer.succeed(True))
when(self.mail_store).add_mail('DRAFTS', mail.raw).thenReturn(defer.succeed(LeapMail('id', 'DRAFTS')))
self.draft_service.update_draft(mail.ident, mail)
inorder.verify(self.mail_store).delete_mail(mail.ident)
inorder.verify(self.mail_store).add_mail('DRAFTS', mail.raw)