コード例 #1
0
 def test_as_dict_replying_with_special_chars(self):
     expected_address = u'"\xc4lbert \xdcbr\xf6" <\xe4\xfc\[email protected]>'
     mail = LeapMail('', 'INBOX',
                     {'From': '=?iso-8859-1?q?=22=C4lbert_=DCbr=F6=22_=3C=E4=FC=F6=40example=2Email=3E?=',
                      'To': '=?iso-8859-1?q?=22=C4lbert_=DCbr=F6=22_=3C=E4=FC=F6=40example=2Email=3E?=',
                      'Cc': '=?iso-8859-1?q?=22=C4lbert_=DCbr=F6=22_=3C=E4=FC=F6=40example=2Email=3E?=',
                      'Subject': '=?iso-8859-1?q?H=E4ll=F6_W=F6rld?='})
     self.assertEqual([expected_address], mail.as_dict()['replying']['all']['to-field'])
     self.assertEqual([expected_address], mail.as_dict()['replying']['all']['cc-field'])
     self.assertEqual(expected_address, mail.as_dict()['replying']['single'])
コード例 #2
0
    def test_as_dict_replying_with_special_chars(self):
        expected_address = u'"\xc4lbert \xdcbr\xf6" <\xe4\xfc\[email protected]>'
        mail = LeapMail('', 'INBOX',
                        {'From': '=?iso-8859-1?q?=22=C4lbert_=DCbr=F6=22_=3C=E4=FC=F6=40example=2Email=3E?=',
                         'To': '=?iso-8859-1?q?=22=C4lbert_=DCbr=F6=22_=3C=E4=FC=F6=40example=2Email=3E?=',
                         'Cc': '=?iso-8859-1?q?=22=C4lbert_=DCbr=F6=22_=3C=E4=FC=F6=40example=2Email=3E?=',
                         'Subject': '=?iso-8859-1?q?H=E4ll=F6_W=F6rld?='})

        self.assertEqual([expected_address], mail.as_dict()['replying']['all']['to-field'])
        self.assertEqual([expected_address], mail.as_dict()['replying']['all']['cc-field'])
        self.assertEqual(expected_address, mail.as_dict()['replying']['single'])
コード例 #3
0
    def test_as_dict_headers_with_special_chars(self):
        expected_address = u'"\xc4lbert \xdcbr\xf6" <\xe4\xfc\[email protected]>'
        expected_subject = u'H\xe4ll\xf6 W\xf6rld'
        mail = LeapMail('', 'INBOX',
                        {'From': '=?iso-8859-1?q?=22=C4lbert_=DCbr=F6=22_=3C=E4=FC=F6=40example=2Email=3E?=',
                         'To': '=?iso-8859-1?q?=22=C4lbert_=DCbr=F6=22_=3C=E4=FC=F6=40example=2Email=3E?=',
                         'Cc': '=?iso-8859-1?q?=22=C4lbert_=DCbr=F6=22_=3C=E4=FC=F6=40example=2Email=3E?=',
                         'Subject': '=?iso-8859-1?q?H=E4ll=F6_W=F6rld?='})

        self.assertEqual(expected_address, mail.as_dict()['header']['from'])
        self.assertEqual([expected_address], mail.as_dict()['header']['to'])
        self.assertEqual([expected_address], mail.as_dict()['header']['cc'])
        self.assertEqual(expected_subject, mail.as_dict()['header']['subject'])
コード例 #4
0
    def test_as_dict_headers_with_special_chars(self):
        expected_address = u'"\xc4lbert \xdcbr\xf6" <\xe4\xfc\[email protected]>'
        expected_subject = u'H\xe4ll\xf6 W\xf6rld'
        mail = LeapMail('', 'INBOX',
                        {'From': '=?iso-8859-1?q?=22=C4lbert_=DCbr=F6=22_=3C=E4=FC=F6=40example=2Email=3E?=',
                         'To': '=?iso-8859-1?q?=22=C4lbert_=DCbr=F6=22_=3C=E4=FC=F6=40example=2Email=3E?=',
                         'Cc': '=?iso-8859-1?q?=22=C4lbert_=DCbr=F6=22_=3C=E4=FC=F6=40example=2Email=3E?=',
                         'Subject': '=?iso-8859-1?q?H=E4ll=F6_W=F6rld?='})

        self.assertEqual(expected_address, mail.as_dict()['header']['from'])
        self.assertEqual([expected_address], mail.as_dict()['header']['to'])
        self.assertEqual([expected_address], mail.as_dict()['header']['cc'])
        self.assertEqual(expected_subject, mail.as_dict()['header']['subject'])
コード例 #5
0
    def test_reply_all_result_does_contain_own_address_if_only_recipient(self):
        my_address = "*****@*****.**"

        with patch("pixelated.adapter.mailstore.leap_mailstore.InputMail.FROM_EMAIL_ADDRESS", my_address):
            mail = LeapMail("", "INBOX", {"From": "*****@*****.**", "To": "*****@*****.**"})

            self.assertEqual(["*****@*****.**"], mail.as_dict()["replying"]["all"]["to-field"])
コード例 #6
0
    def test_as_dict(self):
        mail = LeapMail(
            "doc id",
            "INBOX",
            {"From": "*****@*****.**", "Subject": "A test Mail", "To": "[email protected],[email protected]"},
            ("foo", "bar"),
        )
        self.maxDiff = None
        expected = {
            "header": {
                "from": "*****@*****.**",
                "subject": "A test Mail",
                "to": ["*****@*****.**", "*****@*****.**"],
            },
            "ident": "doc id",
            "mailbox": "inbox",
            "tags": {"foo", "bar"},
            "status": [],
            "body": None,
            "textPlainBody": None,
            "security_casing": {"imprints": [{"state": "no_signature_information"}], "locks": []},
            "replying": {
                "all": {
                    "cc-field": [],
                    "to-field": ["*****@*****.**", "*****@*****.**", "*****@*****.**"],
                },
                "single": "*****@*****.**",
            },
            "attachments": [],
        }

        self.assertEqual(expected, mail.as_dict())
コード例 #7
0
    def test_reply_all_result_does_not_contain_own_address_in_cc(self):
        my_address = "*****@*****.**"

        with patch("pixelated.adapter.mailstore.leap_mailstore.InputMail.FROM_EMAIL_ADDRESS", my_address):
            mail = LeapMail("", "INBOX", {"From": "*****@*****.**", "To": "*****@*****.**", "Cc": my_address})

            self.assertEqual([], mail.as_dict()["replying"]["all"]["cc-field"])
コード例 #8
0
    def test_as_dict(self):
        mail = LeapMail('doc id', 'INBOX', {'From': '*****@*****.**', 'Subject': 'A test Mail', 'To': '[email protected],[email protected]'}, ('foo', 'bar'))

        expected = {
            'header': {
                'from': '*****@*****.**',
                'subject': 'A test Mail',
                'to': ['*****@*****.**', '*****@*****.**'],

            },
            'ident': 'doc id',
            'mailbox': 'inbox',
            'tags': {'foo', 'bar'},
            'status': [],
            'body': None,
            'textPlainBody': None,
            'replying': {'all': {'cc-field': [],
                                 'to-field': ['*****@*****.**',
                                              '*****@*****.**',
                                              '*****@*****.**']},
                         'single': '*****@*****.**'},
            'attachments': []
        }

        self.assertEqual(expected, mail.as_dict())
コード例 #9
0
    def test_as_dict_replying_with_special_chars(self):
        expected_address = u'"\xc4lbert \xdcbr\xf6" <\xe4\xfc\[email protected]>'
        mail = LeapMail(
            "",
            "INBOX",
            {
                "From": "=?iso-8859-1?q?=22=C4lbert_=DCbr=F6=22_=3C=E4=FC=F6=40example=2Email=3E?=",
                "To": "=?iso-8859-1?q?=22=C4lbert_=DCbr=F6=22_=3C=E4=FC=F6=40example=2Email=3E?=",
                "Cc": "=?iso-8859-1?q?=22=C4lbert_=DCbr=F6=22_=3C=E4=FC=F6=40example=2Email=3E?=",
                "Subject": "=?iso-8859-1?q?H=E4ll=F6_W=F6rld?=",
            },
        )

        self.assertEqual([expected_address], mail.as_dict()["replying"]["all"]["to-field"])
        self.assertEqual([expected_address], mail.as_dict()["replying"]["all"]["cc-field"])
        self.assertEqual(expected_address, mail.as_dict()["replying"]["single"])
コード例 #10
0
    def test_as_dict(self):
        mail = LeapMail('doc id', 'INBOX', {'From': '*****@*****.**', 'Subject': 'A test Mail', 'To': '[email protected],[email protected]'}, ('foo', 'bar'))
        self.maxDiff = None
        expected = {
            'header': {
                'from': '*****@*****.**',
                'subject': 'A test Mail',
                'to': ['*****@*****.**', '*****@*****.**'],

            },
            'ident': 'doc id',
            'mailbox': 'inbox',
            'tags': {'foo', 'bar'},
            'status': [],
            'body': None,
            'textPlainBody': None,
            'security_casing': {
                'imprints': [{'state': 'no_signature_information'}],
                'locks': []
            },
            'replying': {'all': {'cc-field': [],
                                 'to-field': ['*****@*****.**',
                                              '*****@*****.**',
                                              '*****@*****.**']},
                         'single': '*****@*****.**'},
            'attachments': []
        }

        self.assertEqual(expected, mail.as_dict())
コード例 #11
0
    def test_as_dict(self):
        mail = LeapMail(
            'doc id', 'INBOX', {
                'From': '*****@*****.**',
                'Subject': 'A test Mail',
                'To': '[email protected],[email protected]'
            }, ('foo', 'bar'))
        self.maxDiff = None
        expected = {
            'header': {
                'from': '*****@*****.**',
                'subject': 'A test Mail',
                'to': ['*****@*****.**', '*****@*****.**'],
            },
            'ident': 'doc id',
            'mailbox': 'inbox',
            'tags': {'foo', 'bar'},
            'status': [],
            'body': None,
            'textPlainBody': None,
            'security_casing': {
                'imprints': [{
                    'state': 'no_signature_information'
                }],
                'locks': []
            },
            'attachments': []
        }

        self.assertEqual(expected, mail.as_dict())
コード例 #12
0
    def test_reply_result_swaps_sender_and_recipient_if_i_am_the_sender(self):
        my_address = "*****@*****.**"

        with patch("pixelated.adapter.mailstore.leap_mailstore.InputMail.FROM_EMAIL_ADDRESS", my_address):
            mail = LeapMail("", "INBOX", {"From": "*****@*****.**", "To": "*****@*****.**"})

            self.assertEqual("*****@*****.**", mail.as_dict()["replying"]["single"])
コード例 #13
0
    def test_as_dict_headers_with_special_chars(self):
        expected_address = u'"\xc4lbert \xdcbr\xf6" <\xe4\xfc\[email protected]>'
        expected_subject = u"H\xe4ll\xf6 W\xf6rld"
        mail = LeapMail(
            "",
            "INBOX",
            {
                "From": "=?iso-8859-1?q?=22=C4lbert_=DCbr=F6=22_=3C=E4=FC=F6=40example=2Email=3E?=",
                "To": "=?iso-8859-1?q?=22=C4lbert_=DCbr=F6=22_=3C=E4=FC=F6=40example=2Email=3E?=",
                "Cc": "=?iso-8859-1?q?=22=C4lbert_=DCbr=F6=22_=3C=E4=FC=F6=40example=2Email=3E?=",
                "Subject": "=?iso-8859-1?q?H=E4ll=F6_W=F6rld?=",
            },
        )

        self.assertEqual(expected_address, mail.as_dict()["header"]["from"])
        self.assertEqual([expected_address], mail.as_dict()["header"]["to"])
        self.assertEqual([expected_address], mail.as_dict()["header"]["cc"])
        self.assertEqual(expected_subject, mail.as_dict()["header"]["subject"])
コード例 #14
0
    def test_reply_result_swaps_sender_and_recipient_if_i_am_the_sender(self):
        my_address = '*****@*****.**'

        with patch('pixelated.adapter.mailstore.leap_mailstore.InputMail.FROM_EMAIL_ADDRESS', my_address):
            mail = LeapMail('', 'INBOX',
                            {'From': '*****@*****.**',
                             'To': '*****@*****.**'})

            self.assertEqual('*****@*****.**', mail.as_dict()['replying']['single'])
コード例 #15
0
    def test_reply_result_swaps_sender_and_recipient_if_i_am_the_sender(self):
        my_address = '*****@*****.**'

        with patch('pixelated.adapter.mailstore.leap_mailstore.InputMail.FROM_EMAIL_ADDRESS', my_address):
            mail = LeapMail('', 'INBOX',
                            {'From': '*****@*****.**',
                             'To': '*****@*****.**'})

            self.assertEqual('*****@*****.**', mail.as_dict()['replying']['single'])
コード例 #16
0
    def test_reply_all_result_does_not_contain_own_address_in_to_with_encoded(self):
        my_address = '*****@*****.**'

        with patch('pixelated.adapter.mailstore.leap_mailstore.InputMail.FROM_EMAIL_ADDRESS', my_address):
            mail = LeapMail('', 'INBOX',
                            {'From': '*****@*****.**',
                             'To': '[email protected], =?iso-8859-1?q?=C4lbert_=3Cmyaddress=40example=2Etest=3E?='})

            self.assertEqual(['*****@*****.**', '*****@*****.**'], mail.as_dict()['replying']['all']['to-field'])
コード例 #17
0
    def test_reply_all_result_does_contain_own_address_if_only_recipient(self):
        my_address = '*****@*****.**'

        with patch('pixelated.adapter.mailstore.leap_mailstore.InputMail.FROM_EMAIL_ADDRESS', my_address):
            mail = LeapMail('', 'INBOX',
                            {'From': '*****@*****.**',
                             'To': '*****@*****.**'})

            self.assertEqual(['*****@*****.**'], mail.as_dict()['replying']['all']['to-field'])
コード例 #18
0
    def test_reply_all_result_does_not_contain_own_address_in_to_with_name(self):
        my_address = '*****@*****.**'

        with patch('pixelated.adapter.mailstore.leap_mailstore.InputMail.FROM_EMAIL_ADDRESS', my_address):
            mail = LeapMail('', 'INBOX',
                            {'From': '*****@*****.**',
                             'To': '[email protected], Folker Bernitt <%s>' % my_address})

            self.assertEqual(['*****@*****.**', '*****@*****.**'], mail.as_dict()['replying']['all']['to-field'])
コード例 #19
0
    def test_reply_all_result_does_contain_own_address_if_only_recipient(self):
        my_address = '*****@*****.**'

        with patch('pixelated.adapter.mailstore.leap_mailstore.InputMail.FROM_EMAIL_ADDRESS', my_address):
            mail = LeapMail('', 'INBOX',
                            {'From': '*****@*****.**',
                             'To': '*****@*****.**'})

            self.assertEqual(['*****@*****.**'], mail.as_dict()['replying']['all']['to-field'])
コード例 #20
0
    def test_reply_all_result_does_not_contain_own_address_in_cc(self):
        my_address = '*****@*****.**'

        with patch('pixelated.adapter.mailstore.leap_mailstore.InputMail.FROM_EMAIL_ADDRESS', my_address):
            mail = LeapMail('', 'INBOX',
                            {'From': '*****@*****.**',
                             'To': '*****@*****.**',
                             'Cc': my_address})

            self.assertEqual([my_address], mail.as_dict()['replying']['all']['cc-field'])
コード例 #21
0
    def test_as_dict_with_body(self):
        body = "some body content"
        mail = LeapMail(
            "doc id",
            "INBOX",
            {"From": "*****@*****.**", "Subject": "A test Mail", "To": "*****@*****.**"},
            ("foo", "bar"),
            body=body,
        )

        self.assertEqual(body, mail.as_dict()["body"])
コード例 #22
0
    def test_as_dict_with_body(self):
        body = 'some body content'
        mail = LeapMail('doc id',
                        'INBOX', {
                            'From': '*****@*****.**',
                            'Subject': 'A test Mail',
                            'To': '*****@*****.**'
                        }, ('foo', 'bar'),
                        body=body)

        self.assertEqual(body, mail.as_dict()['body'])
コード例 #23
0
    def test_reply_all_result_does_not_contain_own_address_in_to_with_spaces(self):
        my_address = '*****@*****.**'

        with patch('pixelated.adapter.mailstore.leap_mailstore.InputMail.FROM_EMAIL_ADDRESS', my_address):
            mail = LeapMail('', 'INBOX',
                            {'From': '*****@*****.**',
                             'To': '[email protected], %s ' % my_address})
            expected_recipients = ['*****@*****.**', '*****@*****.**']
            actual_recipients = mail.as_dict()['replying']['all']['to-field']
            expected_recipients.sort()
            actual_recipients.sort()

            self.assertEqual(expected_recipients, actual_recipients)
コード例 #24
0
    def test_reply_all_does_not_contain_own_address_in_to_field_with_different_encodings(self):
        my_address = '*****@*****.**'

        with patch('pixelated.adapter.mailstore.leap_mailstore.InputMail.FROM_EMAIL_ADDRESS', my_address):
            mail = LeapMail('', 'INBOX',
                            {'From': '*****@*****.**',
                             'To': '[email protected], =?iso-8859-1?q?=C4lbert_=3Cmyaddress=40example=2Etest=3E?='})

            expected_recipients = [u'*****@*****.**', u'*****@*****.**']
            actual_recipients = mail.as_dict()['replying']['all']['to-field']
            expected_recipients.sort()
            actual_recipients.sort()

            self.assertEqual(expected_recipients, actual_recipients)
コード例 #25
0
    def test_reply_all_result_does_not_contain_own_address_in_to_with_encoded(self):
        my_address = "*****@*****.**"

        with patch("pixelated.adapter.mailstore.leap_mailstore.InputMail.FROM_EMAIL_ADDRESS", my_address):
            mail = LeapMail(
                "",
                "INBOX",
                {
                    "From": "*****@*****.**",
                    "To": "[email protected], =?iso-8859-1?q?=C4lbert_=3Cmyaddress=40example=2Etest=3E?=",
                },
            )

            self.assertEqual(
                ["*****@*****.**", "*****@*****.**"], mail.as_dict()["replying"]["all"]["to-field"]
            )
コード例 #26
0
    def test_as_dict_with_attachments(self):
        attachment_info = AttachmentInfo('id',
                                         'name',
                                         'encoding',
                                         ctype='text/plain',
                                         size=2)
        mail = LeapMail('doc id', 'INBOX', attachments=[attachment_info])

        self.assertEqual([{
            'ident': 'id',
            'name': 'name',
            'encoding': 'encoding',
            'content-type': 'text/plain',
            'size': 2
        }],
                         mail.as_dict()['attachments'])
コード例 #27
0
    def test_as_dict_with_attachments(self):
        mail = LeapMail("doc id", "INBOX", attachments=[AttachmentInfo("id", "name", "encoding")])

        self.assertEqual([{"ident": "id", "name": "name", "encoding": "encoding"}], mail.as_dict()["attachments"])
コード例 #28
0
    def test_as_dict_with_attachments(self):
        mail = LeapMail('doc id', 'INBOX', attachments=[AttachmentInfo('id', 'name', 'encoding')])

        self.assertEqual([{'ident': 'id', 'name': 'name', 'encoding': 'encoding'}],
                         mail.as_dict()['attachments'])
コード例 #29
0
    def test_as_dict_with_body(self):
        body = 'some body content'
        mail = LeapMail('doc id', 'INBOX', {'From': '*****@*****.**', 'Subject': 'A test Mail', 'To': '*****@*****.**'}, ('foo', 'bar'), body=body)

        self.assertEqual(body, mail.as_dict()['body'])
コード例 #30
0
    def test_as_dict_with_attachments(self):
        attachment_info = AttachmentInfo('id', 'name', 'encoding', ctype='text/plain', size=2)
        mail = LeapMail('doc id', 'INBOX', attachments=[attachment_info])

        self.assertEqual([{'ident': 'id', 'name': 'name', 'encoding': 'encoding', 'content-type': 'text/plain', 'size': 2}],
                         mail.as_dict()['attachments'])
コード例 #31
0
    def test_as_dict_with_mixed_encodings(self):
        subject = 'Another test with =?iso-8859-1?B?3G1s5Px0?= =?iso-8859-1?Q?s?='
        mail = LeapMail('', 'INBOX',
                        {'Subject': subject})

        self.assertEqual(u'Another test with Ümläüts', mail.as_dict()['header']['subject'])
コード例 #32
0
    def test_as_dict_with_mixed_encodings(self):
        subject = "Another test with =?iso-8859-1?B?3G1s5Px0?= =?iso-8859-1?Q?s?="
        mail = LeapMail("", "INBOX", {"Subject": subject})

        self.assertEqual(u"Another test with Ümläüts", mail.as_dict()["header"]["subject"])
コード例 #33
0
    def test_as_dict_with_mixed_encodings(self):
        subject = 'Another test with =?iso-8859-1?B?3G1s5Px0?= =?iso-8859-1?Q?s?='
        mail = LeapMail('', 'INBOX', {'Subject': subject})

        self.assertEqual(u'Another test with Ümläüts',
                         mail.as_dict()['header']['subject'])
コード例 #34
0
    def test_as_dict_with_attachments(self):
        mail = LeapMail('doc id', 'INBOX', attachments=[AttachmentInfo('id', 'name', 'encoding')])

        self.assertEqual([{'ident': 'id', 'name': 'name', 'encoding': 'encoding'}],
                         mail.as_dict()['attachments'])