summaryrefslogtreecommitdiff
path: root/service/test/unit/adapter/test_mail.py
diff options
context:
space:
mode:
authorGiovane <giovaneliberato@gmail.com>2016-01-14 18:34:00 -0200
committerBruno Wagner <bwagner@riseup.net>2016-01-15 11:11:55 -0200
commitcd831d1dfc42c2a0d292fe5c1b7f497b2ca393eb (patch)
tree4069da65211b163f7718b8628349976748a6d0ee /service/test/unit/adapter/test_mail.py
parent36972dc55f64100f4e056130cc1d32a266785a41 (diff)
Removes InputMail.FROM_EMAIL_ADDRESS constant #578
- Created the replier component to generate the reply dict for the email. This was needed to decouple the InputMail from the need to know who is the logged user.
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')