From cd831d1dfc42c2a0d292fe5c1b7f497b2ca393eb Mon Sep 17 00:00:00 2001 From: Giovane Date: Thu, 14 Jan 2016 18:34:00 -0200 Subject: 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. --- service/test/unit/adapter/test_mail.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'service/test/unit/adapter/test_mail.py') 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

Hello html world!

' @@ -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') -- cgit v1.2.3