summaryrefslogtreecommitdiff
path: root/service/test/unit/adapter/test_mail.py
diff options
context:
space:
mode:
Diffstat (limited to 'service/test/unit/adapter/test_mail.py')
-rw-r--r--service/test/unit/adapter/test_mail.py16
1 files changed, 7 insertions, 9 deletions
diff --git a/service/test/unit/adapter/test_mail.py b/service/test/unit/adapter/test_mail.py
index 6e4943fa..d66eddd9 100644
--- a/service/test/unit/adapter/test_mail.py
+++ b/service/test/unit/adapter/test_mail.py
@@ -81,7 +81,7 @@ class InputMailTest(unittest.TestCase):
mail_dict['header']['cc'] = ''
mail_dict['header']['subject'] = ''
- mime_multipart = InputMail.from_dict(mail_dict).to_mime_multipart()
+ mime_multipart = InputMail.from_dict(mail_dict, from_address='pixelated@org').to_mime_multipart()
self.assertNotRegexpMatches(mime_multipart.as_string(), "\nTo: \n")
self.assertNotRegexpMatches(mime_multipart.as_string(), "\nBcc: \n")
@@ -99,14 +99,14 @@ class InputMailTest(unittest.TestCase):
}
}
- result = InputMail.from_dict(mail_single_recipient).raw
+ result = InputMail.from_dict(mail_single_recipient, from_address='pixelated@org').raw
self.assertRegexpMatches(result, 'To: to@pixelated.org')
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()
+ mime_multipart = InputMail.from_dict(simple_mail_dict(), from_address='pixelated@org').to_mime_multipart()
self.assertRegexpMatches(mime_multipart.as_string(), "\nTo: to@pixelated.org, anotherto@pixelated.org\n")
self.assertRegexpMatches(mime_multipart.as_string(), "\nCc: cc@pixelated.org, anothercc@pixelated.org\n")
@@ -120,20 +120,18 @@ class InputMailTest(unittest.TestCase):
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()
+ mime_multipart = InputMail.from_dict(mail_dict, from_address='pixelated@org').to_mime_multipart()
expected_part_of_encoded_to = 'Iiwgw4QsIGwsIGIsIGUsIHIsIHQsICAsIMOcLCBiLCByLCDDtiwgICwgw7As'
self.assertRegexpMatches(mime_multipart.as_string(), expected_part_of_encoded_to)
def test_smtp_format(self):
- InputMail.FROM_EMAIL_ADDRESS = 'pixelated@org'
-
- smtp_format = InputMail.from_dict(simple_mail_dict()).to_smtp_format()
+ smtp_format = InputMail.from_dict(simple_mail_dict(), from_address='pixelated@org').to_smtp_format()
self.assertRegexpMatches(smtp_format, "\nFrom: pixelated@org")
def test_to_mime_multipart_handles_alternative_bodies(self):
- mime_multipart = InputMail.from_dict(multipart_mail_dict()).to_mime_multipart()
+ mime_multipart = InputMail.from_dict(multipart_mail_dict(), from_address='pixelated@org').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>'
@@ -142,7 +140,7 @@ class InputMailTest(unittest.TestCase):
self.assertRegexpMatches(mime_multipart.as_string(), part_two)
def test_raw_with_attachment_data(self):
- input_mail = InputMail.from_dict(with_attachment_mail_dict())
+ input_mail = InputMail.from_dict(with_attachment_mail_dict(), from_address='pixelated@org')
attachment = MIMENonMultipart('text', 'plain', Content_Disposition='attachment; filename=ayoyo.txt')
attachment.set_payload('Hello World')