Exemplo n.º 1
0
    def test_multipart_message(self):
        msg = EmailMessage('*****@*****.**', '*****@*****.**', 'subject')
        msg.add_inline_attachment('body')
        self.assertEqualDiff(SIMPLE_MULTIPART_MESSAGE, msg.as_string(BOUNDARY))

        msg = EmailMessage('*****@*****.**', '*****@*****.**', 'subject', 'body')
        msg.add_inline_attachment(u'a\nb\nc\nd\ne\n', 'lines.txt', 'x-subtype')
        self.assertEqualDiff(COMPLEX_MULTIPART_MESSAGE % 'x-subtype',
                             msg.as_string(BOUNDARY))
Exemplo n.º 2
0
    def test_multipart_message(self):
        msg = EmailMessage('*****@*****.**', '*****@*****.**', 'subject')
        msg.add_inline_attachment('body')
        self.assertEqualDiff(SIMPLE_MULTIPART_MESSAGE, msg.as_string(BOUNDARY))

        msg = EmailMessage('*****@*****.**', '*****@*****.**', 'subject', 'body')
        msg.add_inline_attachment(u'a\nb\nc\nd\ne\n', 'lines.txt', 'x-subtype')
        self.assertEqualDiff(COMPLEX_MULTIPART_MESSAGE % 'x-subtype',
                msg.as_string(BOUNDARY))
Exemplo n.º 3
0
 def test_simple_message(self):
     pairs = {
         'body': SIMPLE_MESSAGE_ASCII,
         u'b\xf3dy': SIMPLE_MESSAGE_UTF8,
         'b\xc3\xb3dy': SIMPLE_MESSAGE_UTF8,
         'b\xf4dy': SIMPLE_MESSAGE_8BIT,
     }
     for body, expected in pairs.items():
         msg = EmailMessage('*****@*****.**', '*****@*****.**', 'subject', body)
         self.assertEqualDiff(expected, msg.as_string())
Exemplo n.º 4
0
 def test_simple_message(self):
     pairs = {
         'body': SIMPLE_MESSAGE_ASCII,
         u'b\xf3dy': SIMPLE_MESSAGE_UTF8,
         'b\xc3\xb3dy': SIMPLE_MESSAGE_UTF8,
         'b\xf4dy': SIMPLE_MESSAGE_8BIT,
     }
     for body, expected in pairs.items():
         msg = EmailMessage('*****@*****.**', '*****@*****.**', 'subject', body)
         self.assertEqualDiff(expected, msg.as_string())
Exemplo n.º 5
0
 def test_empty_message(self):
     msg = EmailMessage('*****@*****.**', '*****@*****.**', 'subject')
     self.assertEqualDiff(EMPTY_MESSAGE , msg.as_string())
Exemplo n.º 6
0
 def test_multiple_destinations(self):
     to_addresses = [ '*****@*****.**', '*****@*****.**', '*****@*****.**' ]
     msg = EmailMessage('*****@*****.**', to_addresses, 'subject')
     self.assertContainsRe(msg.as_string(), 'To: ' +
             ', '.join(to_addresses)) # re.M can't be passed, so no ^$
Exemplo n.º 7
0
 def test_multipart_message_complex(self):
     msg = EmailMessage('*****@*****.**', '*****@*****.**', 'subject', 'body')
     msg.add_inline_attachment(u'a\nb\nc\nd\ne\n', 'lines.txt', 'x-subtype')
     self.assertEqualDiff(complex_multipart_message('x-subtype'),
                          msg.as_string(BOUNDARY))
Exemplo n.º 8
0
 def test_multipart_message_simple(self):
     msg = EmailMessage('*****@*****.**', '*****@*****.**', 'subject')
     msg.add_inline_attachment('body')
     self.assertEqualDiff(simple_multipart_message(),
                          msg.as_string(BOUNDARY))
Exemplo n.º 9
0
 def test_empty_message(self):
     msg = EmailMessage('*****@*****.**', '*****@*****.**', 'subject')
     self.assertEqualDiff(EMPTY_MESSAGE, msg.as_string())
Exemplo n.º 10
0
 def test_multiple_destinations(self):
     to_addresses = ['*****@*****.**', '*****@*****.**', '*****@*****.**']
     msg = EmailMessage('*****@*****.**', to_addresses, 'subject')
     self.assertContainsRe(
         msg.as_string(),
         'To: ' + ', '.join(to_addresses))  # re.M can't be passed, so no ^$
Exemplo n.º 11
0
 def test_multipart_message_complex(self):
     msg = EmailMessage('*****@*****.**', '*****@*****.**', 'subject', 'body')
     msg.add_inline_attachment(u'a\nb\nc\nd\ne\n', 'lines.txt', 'x-subtype')
     self.assertEqualDiff(complex_multipart_message('x-subtype'),
                          msg.as_string(BOUNDARY))
Exemplo n.º 12
0
 def test_multipart_message_simple(self):
     msg = EmailMessage('*****@*****.**', '*****@*****.**', 'subject')
     msg.add_inline_attachment('body')
     self.assertEqualDiff(simple_multipart_message(),
                          msg.as_string(BOUNDARY))