summaryrefslogtreecommitdiff
path: root/service/test
diff options
context:
space:
mode:
authorFábio Pio <fpio@thoughtworks.com>2014-12-16 21:11:12 -0200
committerFábio Pio <fpio@thoughtworks.com>2014-12-16 21:11:12 -0200
commitbd7fd89ee715c3e24f0451466c93d9c2091a5e61 (patch)
tree79b95da4e56f4bc2eb6a7ebc4b99b55510542d47 /service/test
parent614b749b9813ed9bef0bc1f70ea223ca86927df4 (diff)
Fix #195 and #198 special characters handling
Added check to see if message body is base64, properly decode the body if they are Saving a draft with special characters now properly uses utf-8, that means it will send the body base64 encoded
Diffstat (limited to 'service/test')
-rw-r--r--service/test/unit/adapter/mail_test.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/service/test/unit/adapter/mail_test.py b/service/test/unit/adapter/mail_test.py
index 10886a27..342f1e86 100644
--- a/service/test/unit/adapter/mail_test.py
+++ b/service/test/unit/adapter/mail_test.py
@@ -20,7 +20,7 @@ from pixelated.adapter.mail import PixelatedMail, InputMail
from mockito import *
from test.support import test_helper
import dateutil.parser as dateparser
-
+import base64
class TestPixelatedMail(unittest.TestCase):
def setUp(self):
@@ -170,6 +170,17 @@ class TestPixelatedMail(unittest.TestCase):
mail.raw
+ def test_that_body_understands_base64(self):
+ body = "bl\xe1"
+ encoded_body = base64.b64encode(body)
+
+ fdoc, hdoc, bdoc = test_helper.leap_mail()
+ parts = {'alternatives': []}
+ parts['alternatives'].append({'content': encoded_body, 'headers': {'Content-Transfer-Encoding': 'base64'}})
+ mail = PixelatedMail.from_soledad(fdoc, hdoc, bdoc, soledad_querier=self.querier, parts=parts)
+
+ self.assertEquals(body, mail.body)
+
class InputMailTest(unittest.TestCase):
mail_dict = lambda x: {
'body': 'Este \xe9 o corpo',
@@ -222,7 +233,7 @@ class InputMailTest(unittest.TestCase):
self.assertRegexpMatches(mime_multipart.as_string(), "\nBcc: bcc@pixelated.org, anotherbcc@pixelated.org\n")
self.assertRegexpMatches(mime_multipart.as_string(), "\nDate: date now\n")
self.assertRegexpMatches(mime_multipart.as_string(), "\nSubject: Oi\n")
- self.assertRegexpMatches(mime_multipart.as_string(), "\nEste \xe9 o corpo")
+ self.assertRegexpMatches(mime_multipart.as_string(), base64.b64encode(self.mail_dict()['body']))
def test_smtp_format(self):
InputMail.FROM_EMAIL_ADDRESS = 'pixelated@org'