Fix tests with Products.MailHost 4.10.

This commit is contained in:
Maurits van Rees 2020-09-23 15:26:30 +02:00
parent 7a2b49c7fb
commit e4bcf2f53c
No known key found for this signature in database
GPG Key ID: AAEC1E5318E6FCCE
2 changed files with 6 additions and 1 deletions

2
news/3178.bugfix Normal file
View File

@ -0,0 +1,2 @@
Fix tests with Products.MailHost 4.10.
[maurits]

View File

@ -65,7 +65,8 @@ class TestUserNotificationUnit(unittest.TestCase):
self.assertEqual(len(self.mailhost.messages), 1) self.assertEqual(len(self.mailhost.messages), 1)
self.assertTrue(self.mailhost.messages[0]) self.assertTrue(self.mailhost.messages[0])
msg = str(self.mailhost.messages[0]) msg = self.mailhost.messages[0]
msg = msg.decode("utf-8")
self.assertTrue('To: john@plone.test' in msg) self.assertTrue('To: john@plone.test' in msg)
self.assertTrue('From: portal@plone.test' in msg) self.assertTrue('From: portal@plone.test' in msg)
# We expect the headers to be properly header encoded (7-bit): # We expect the headers to be properly header encoded (7-bit):
@ -207,6 +208,7 @@ class TestModeratorNotificationUnit(unittest.TestCase):
self.assertEqual(len(self.mailhost.messages), 1) self.assertEqual(len(self.mailhost.messages), 1)
self.assertTrue(self.mailhost.messages[0]) self.assertTrue(self.mailhost.messages[0])
msg = self.mailhost.messages[0] msg = self.mailhost.messages[0]
msg = msg.decode("utf-8")
self.assertTrue('To: portal@plone.test' in msg) self.assertTrue('To: portal@plone.test' in msg)
self.assertTrue('From: portal@plone.test' in msg) self.assertTrue('From: portal@plone.test' in msg)
# We expect the headers to be properly header encoded (7-bit): # We expect the headers to be properly header encoded (7-bit):
@ -244,6 +246,7 @@ class TestModeratorNotificationUnit(unittest.TestCase):
self.assertEqual(len(self.mailhost.messages), 1) self.assertEqual(len(self.mailhost.messages), 1)
msg = self.mailhost.messages[0] msg = self.mailhost.messages[0]
msg = msg.decode("utf-8")
if not isinstance(msg, str): if not isinstance(msg, str):
self.assertTrue('test@example.com' in msg.mto) self.assertTrue('test@example.com' in msg.mto)
else: else: