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


Python InputMail.from_dict方法代码示例

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


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

示例1: render_PUT

# 需要导入模块: from pixelated.adapter.model.mail import InputMail [as 别名]
# 或者: from pixelated.adapter.model.mail.InputMail import from_dict [as 别名]
    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
开发者ID:kaeff,项目名称:pixelated-user-agent,代码行数:29,代码来源:mails_resource.py

示例2: send_mail

# 需要导入模块: from pixelated.adapter.model.mail import InputMail [as 别名]
# 或者: from pixelated.adapter.model.mail.InputMail import from_dict [as 别名]
    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)
开发者ID:codergolem,项目名称:pixelated-user-agent,代码行数:9,代码来源:mail_service.py

示例3: test_if_recipient_doubled_in_fields_send_only_in_bcc

# 需要导入模块: from pixelated.adapter.model.mail import InputMail [as 别名]
# 或者: from pixelated.adapter.model.mail.InputMail import from_dict [as 别名]
    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)
开发者ID:Josue23,项目名称:pixelated-user-agent,代码行数:10,代码来源:test_mail_service.py

示例4: test_if_deduplicates_when_recipient_repeated_in_field

# 需要导入模块: from pixelated.adapter.model.mail import InputMail [as 别名]
# 或者: from pixelated.adapter.model.mail.InputMail import from_dict [as 别名]
    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)
开发者ID:Josue23,项目名称:pixelated-user-agent,代码行数:10,代码来源:test_mail_service.py

示例5: test_to_mime_multipart_handles_alternative_bodies

# 需要导入模块: from pixelated.adapter.model.mail import InputMail [as 别名]
# 或者: from pixelated.adapter.model.mail.InputMail import from_dict [as 别名]
    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)
开发者ID:tcz001,项目名称:pixelated-user-agent,代码行数:10,代码来源:test_mail.py

示例6: test_update_draft

# 需要导入模块: from pixelated.adapter.model.mail import InputMail [as 别名]
# 或者: from pixelated.adapter.model.mail.InputMail import from_dict [as 别名]
    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)
开发者ID:rdoh,项目名称:pixelated-user-agent,代码行数:10,代码来源:test_draft_service.py

示例7: test_update_draft

# 需要导入模块: from pixelated.adapter.model.mail import InputMail [as 别名]
# 或者: from pixelated.adapter.model.mail.InputMail import from_dict [as 别名]
    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)
开发者ID:EderRoger,项目名称:pixelated-user-agent,代码行数:10,代码来源:test_draft_service.py

示例8: test_iterates_over_recipients

# 需要导入模块: from pixelated.adapter.model.mail import InputMail [as 别名]
# 或者: from pixelated.adapter.model.mail.InputMail import from_dict [as 别名]
    def test_iterates_over_recipients(self):
        input_mail = InputMail.from_dict(mail_dict(), from_address='[email protected]')

        when(OutgoingMail).send_message(any(), any()).thenReturn(defer.succeed(None))

        yield self.sender.sendmail(input_mail)

        for recipient in flatten([input_mail.to, input_mail.cc, input_mail.bcc]):
            verify(OutgoingMail).send_message(any(), TwistedSmtpUserCapture(recipient))
开发者ID:Josue23,项目名称:pixelated-user-agent,代码行数:11,代码来源:test_mail_sender.py

示例9: test_single_recipient

# 需要导入模块: from pixelated.adapter.model.mail import InputMail [as 别名]
# 或者: from pixelated.adapter.model.mail.InputMail import from_dict [as 别名]
    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]")
开发者ID:phazel,项目名称:pixelated-user-agent,代码行数:11,代码来源:test_mail.py

示例10: test_update_draft

# 需要导入模块: from pixelated.adapter.model.mail import InputMail [as 别名]
# 或者: from pixelated.adapter.model.mail.InputMail import from_dict [as 别名]
    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)
开发者ID:pixelated,项目名称:pixelated-user-agent,代码行数:11,代码来源:test_draft_service.py

示例11: test_to_mime_multipart_with_special_chars

# 需要导入模块: from pixelated.adapter.model.mail import InputMail [as 别名]
# 或者: from pixelated.adapter.model.mail.InputMail import from_dict [as 别名]
    def test_to_mime_multipart_with_special_chars(self):
        mail_dict = simple_mail_dict()
        mail_dict['header']['to'] = u'"Älbert Übrö \xF0\x9F\x92\xA9" <äüö@example.mail>'
        pixelated.support.date.mail_date_now = lambda: 'date now'

        mime_multipart = InputMail.from_dict(mail_dict).to_mime_multipart()

        expected_part_of_encoded_to = 'Iiwgw4QsIGwsIGIsIGUsIHIsIHQsICAsIMOcLCBiLCByLCDDtiwgICwgw7As'
        self.assertRegexpMatches(mime_multipart.as_string(), expected_part_of_encoded_to)
开发者ID:tcz001,项目名称:pixelated-user-agent,代码行数:11,代码来源:test_mail.py

示例12: test_iterates_over_recipients

# 需要导入模块: from pixelated.adapter.model.mail import InputMail [as 别名]
# 或者: from pixelated.adapter.model.mail.InputMail import from_dict [as 别名]
    def test_iterates_over_recipients(self):
        sender = MailSender(self._smtp_config, self._keymanager_mock)
        input_mail = InputMail.from_dict(mail_dict())

        when(OutgoingMail).send_message(any(), any()).thenAnswer(lambda: defer.succeed(None))

        yield sender.sendmail(input_mail)

        for recipient in flatten([input_mail.to, input_mail.cc, input_mail.bcc]):
            verify(OutgoingMail).send_message(any(), TwistedSmtpUserCapture(recipient))
开发者ID:rdoh,项目名称:pixelated-user-agent,代码行数:12,代码来源:test_mail_sender.py

示例13: test_iterates_over_recipients_and_send_whitout_bcc_field

# 需要导入模块: from pixelated.adapter.model.mail import InputMail [as 别名]
# 或者: from pixelated.adapter.model.mail.InputMail import from_dict [as 别名]
    def test_iterates_over_recipients_and_send_whitout_bcc_field(self):
        input_mail = InputMail.from_dict(mail_dict())
        bccs = input_mail.bcc

        when(OutgoingMail).send_message(any(), any()).thenReturn(defer.succeed(None))

        yield self.sender.sendmail(input_mail)

        for recipient in flatten([input_mail.to, input_mail.cc, input_mail.bcc]):
            verify(OutgoingMail).send_message(MailToSmtpFormatCapture(recipient, bccs), TwistedSmtpUserCapture(recipient))
开发者ID:tcz001,项目名称:pixelated-user-agent,代码行数:12,代码来源:test_mail_sender.py

示例14: send_mail

# 需要导入模块: from pixelated.adapter.model.mail import InputMail [as 别名]
# 或者: from pixelated.adapter.model.mail.InputMail import from_dict [as 别名]
    def send_mail(self, content_dict):
        mail = InputMail.from_dict(content_dict)
        draft_id = content_dict.get('ident')

        def move_to_sent(_):
            return self.move_to_sent(draft_id, mail)

        deferred = self.mail_sender.sendmail(mail)
        deferred.addCallback(move_to_sent)
        return deferred
开发者ID:marcwebbie,项目名称:pixelated-user-agent,代码行数:12,代码来源:mail_service.py

示例15: test_to_mime_multipart

# 需要导入模块: from pixelated.adapter.model.mail import InputMail [as 别名]
# 或者: from pixelated.adapter.model.mail.InputMail import from_dict [as 别名]
    def test_to_mime_multipart(self):
        pixelated.support.date.mail_date_now = lambda: 'date now'

        mime_multipart = InputMail.from_dict(simple_mail_dict()).to_mime_multipart()

        self.assertRegexpMatches(mime_multipart.as_string(), "\nTo: [email protected], [email protected]\n")
        self.assertRegexpMatches(mime_multipart.as_string(), "\nCc: [email protected], [email protected]\n")
        self.assertRegexpMatches(mime_multipart.as_string(), "\nBcc: [email protected], [email protected]\n")
        self.assertRegexpMatches(mime_multipart.as_string(), "\nDate: date now\n")
        self.assertRegexpMatches(mime_multipart.as_string(), "\nSubject: Oi\n")
        self.assertRegexpMatches(mime_multipart.as_string(), base64.b64encode(simple_mail_dict()['body']))
开发者ID:tcz001,项目名称:pixelated-user-agent,代码行数:13,代码来源:test_mail.py


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