Commit 2293b357 authored by Jérome Perrin's avatar Jérome Perrin

testDeferredStyle py3

parent b1418103
...@@ -133,7 +133,7 @@ class TestDeferredStyleBase(DeferredStyleTestCase): ...@@ -133,7 +133,7 @@ class TestDeferredStyleBase(DeferredStyleTestCase):
self.assertNotEqual(last_message, ()) self.assertNotEqual(last_message, ())
mfrom, mto, message_text = last_message mfrom, mto, message_text = last_message
self.assertEqual('"%s" <%s>' % (self.first_name, self.recipient_email_address), mto[0]) self.assertEqual('"%s" <%s>' % (self.first_name, self.recipient_email_address), mto[0])
mail_message = email.message_from_string(message_text) mail_message = email.message_from_string(message_text.decode())
for part in mail_message.walk(): for part in mail_message.walk():
content_type = part.get_content_type() content_type = part.get_content_type()
file_name = part.get_filename() file_name = part.get_filename()
...@@ -198,7 +198,7 @@ class TestDeferredStyleBase(DeferredStyleTestCase): ...@@ -198,7 +198,7 @@ class TestDeferredStyleBase(DeferredStyleTestCase):
self.assertNotEqual(last_message, ()) self.assertNotEqual(last_message, ())
mfrom, mto, message_text = last_message mfrom, mto, message_text = last_message
self.assertEqual('"%s" <%s>' % (self.first_name, self.recipient_email_address), mto[0]) self.assertEqual('"%s" <%s>' % (self.first_name, self.recipient_email_address), mto[0])
mail_message = email.message_from_string(message_text) mail_message = email.message_from_string(message_text.decode())
for part in mail_message.walk(): for part in mail_message.walk():
content_type = part.get_content_type() content_type = part.get_content_type()
if content_type == "text/html": if content_type == "text/html":
...@@ -236,7 +236,7 @@ class TestDeferredStyleBase(DeferredStyleTestCase): ...@@ -236,7 +236,7 @@ class TestDeferredStyleBase(DeferredStyleTestCase):
self.assertNotEqual(last_message, ()) self.assertNotEqual(last_message, ())
mfrom, mto, message_text = last_message mfrom, mto, message_text = last_message
self.assertEqual('"%s" <%s>' % (self.first_name, self.recipient_email_address), mto[0]) self.assertEqual('"%s" <%s>' % (self.first_name, self.recipient_email_address), mto[0])
mail_message = email.message_from_string(message_text) mail_message = email.message_from_string(message_text.decode())
for part in mail_message.walk(): for part in mail_message.walk():
content_type = part.get_content_type() content_type = part.get_content_type()
if content_type == "text/html": if content_type == "text/html":
...@@ -260,7 +260,7 @@ class TestDeferredStyleBase(DeferredStyleTestCase): ...@@ -260,7 +260,7 @@ class TestDeferredStyleBase(DeferredStyleTestCase):
self.assertNotEqual(last_message, ()) self.assertNotEqual(last_message, ())
mfrom, mto, message_text = last_message mfrom, mto, message_text = last_message
self.assertEqual('"%s" <%s>' % (self.first_name, self.recipient_email_address), mto[0]) self.assertEqual('"%s" <%s>' % (self.first_name, self.recipient_email_address), mto[0])
mail_message = email.message_from_string(message_text) mail_message = email.message_from_string(message_text.decode())
for part in mail_message.walk(): for part in mail_message.walk():
content_type = part.get_content_type() content_type = part.get_content_type()
if content_type == "text/html": if content_type == "text/html":
...@@ -285,7 +285,7 @@ class TestDeferredStyleBase(DeferredStyleTestCase): ...@@ -285,7 +285,7 @@ class TestDeferredStyleBase(DeferredStyleTestCase):
self.assertNotEqual(last_message, ()) self.assertNotEqual(last_message, ())
mfrom, mto, message_text = last_message mfrom, mto, message_text = last_message
self.assertEqual('"%s" <%s>' % (self.first_name, self.recipient_email_address), mto[0]) self.assertEqual('"%s" <%s>' % (self.first_name, self.recipient_email_address), mto[0])
mail_message = email.message_from_string(message_text) mail_message = email.message_from_string(message_text.decode())
for part in mail_message.walk(): for part in mail_message.walk():
content_type = part.get_content_type() content_type = part.get_content_type()
if content_type == self.content_type: if content_type == self.content_type:
...@@ -315,7 +315,7 @@ class TestDeferredStyleBase(DeferredStyleTestCase): ...@@ -315,7 +315,7 @@ class TestDeferredStyleBase(DeferredStyleTestCase):
'HTTP_ACCEPT_LANGUAGE': 'fr;q=0.9,en;q=0.8', 'HTTP_ACCEPT_LANGUAGE': 'fr;q=0.9,en;q=0.8',
}) })
self.tic() self.tic()
mail_message = email.message_from_string(self.portal.MailHost._last_message[2]) mail_message = email.message_from_string(self.portal.MailHost._last_message[2].decode())
# mail subject is translated # mail subject is translated
self.assertEqual('Historique', mail_message['subject']) self.assertEqual('Historique', mail_message['subject'])
# content is translated # content is translated
...@@ -345,11 +345,11 @@ class TestDeferredStyleBase(DeferredStyleTestCase): ...@@ -345,11 +345,11 @@ class TestDeferredStyleBase(DeferredStyleTestCase):
'HTTP_COOKIE': 'LOCALIZER_LANGUAGE="fr"', 'HTTP_COOKIE': 'LOCALIZER_LANGUAGE="fr"',
}) })
self.tic() self.tic()
mail_message = email.message_from_string(self.portal.MailHost._last_message[2]) mail_message = email.message_from_string(self.portal.MailHost._last_message[2].decode())
# mail subject is translated # mail subject is translated
self.assertEqual('Historique', mail_message['subject']) self.assertEqual('Historique', mail_message['subject'])
# content is translated # content is translated
mail_message = email.message_from_string(self.portal.MailHost._last_message[2]) mail_message = email.message_from_string(self.portal.MailHost._last_message[2].decode())
part, = [x for x in mail_message.walk() if x.get_content_type() == self.content_type] part, = [x for x in mail_message.walk() if x.get_content_type() == self.content_type]
self.assertIn( self.assertIn(
'Historique', 'Historique',
...@@ -450,7 +450,7 @@ class TestDeferredStyleBase(DeferredStyleTestCase): ...@@ -450,7 +450,7 @@ class TestDeferredStyleBase(DeferredStyleTestCase):
# inspect the report as text and check the selection was initialized from # inspect the report as text and check the selection was initialized from
# request parameter. # request parameter.
mail_message = email.message_from_string(self.portal.MailHost._last_message[2]) mail_message = email.message_from_string(self.portal.MailHost._last_message[2].decode())
part, = [x for x in mail_message.walk() if x.get_content_type() == self.content_type] part, = [x for x in mail_message.walk() if x.get_content_type() == self.content_type]
doc = self.portal.document_module.newContent( doc = self.portal.document_module.newContent(
...@@ -487,7 +487,7 @@ class TestODSDeferredStyle(TestDeferredStyleBase): ...@@ -487,7 +487,7 @@ class TestODSDeferredStyle(TestDeferredStyleBase):
self.assertNotEqual(last_message, ()) self.assertNotEqual(last_message, ())
mfrom, mto, message_text = last_message mfrom, mto, message_text = last_message
self.assertEqual('"%s" <%s>' % (self.first_name, self.recipient_email_address), mto[0]) self.assertEqual('"%s" <%s>' % (self.first_name, self.recipient_email_address), mto[0])
mail_message = email.message_from_string(message_text) mail_message = email.message_from_string(message_text.decode())
for part in mail_message.walk(): for part in mail_message.walk():
content_type = part.get_content_type() content_type = part.get_content_type()
file_name = part.get_filename() file_name = part.get_filename()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment