Fix tests with Products.MailHost 4.11.

Fixes https://github.com/plone/plone.app.discussion/issues/174
This commit is contained in:
Maurits van Rees 2021-01-22 16:29:35 +01:00
parent dd7865bdd6
commit 4d36d0b342
No known key found for this signature in database
GPG Key ID: AAEC1E5318E6FCCE
2 changed files with 21 additions and 16 deletions

2
news/174.bugfix Normal file
View File

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

View File

@ -67,23 +67,26 @@ class TestUserNotificationUnit(unittest.TestCase):
self.assertTrue(self.mailhost.messages[0])
msg = self.mailhost.messages[0]
msg = msg.decode("utf-8")
self.assertTrue('To: john@plone.test' in msg)
self.assertTrue('From: portal@plone.test' in msg)
self.assertIn('To: john@plone.test', msg)
self.assertIn('From: portal@plone.test', msg)
# We expect the headers to be properly header encoded (7-bit):
self.assertTrue(
'Subject: =?utf-8?q?A_comment_has_been_posted=2E?=\n'
in msg)
self.assertIn(
'Subject: =?utf-8?q?A_comment_has_been_posted=2E?=',
msg)
# The output should be encoded in a reasonable manner
# (in this case quoted-printable):
self.assertTrue(
'A comment on "K=C3=B6lle Alaaf" has been posted here:'
in msg)
self.assertTrue(
'http://nohost/plone/d=\noc1/view#{0}'.format(comment_id)
in msg)
self.assertTrue('Comment text' in msg)
self.assertFalse('Approve comment' in msg)
self.assertFalse('Delete comment' in msg)
# (in this case quoted-printable).
# Depending on which Python version and which Products.MailHost version,
# you may get lines separated by '\n' or '\r\n' in here.
msg = msg.replace('\r\n', '\n')
self.assertIn(
'A comment on "K=C3=B6lle Alaaf" has been posted here:',
msg)
self.assertIn(
'http://nohost/plone/d=\noc1/view#{0}'.format(comment_id),
msg)
self.assertIn('Comment text', msg)
self.assertNotIn('Approve comment', msg)
self.assertNotIn('Delete comment', msg)
def test_do_not_notify_user_when_notification_is_disabled(self):
registry = queryUtility(IRegistry)
@ -213,7 +216,7 @@ class TestModeratorNotificationUnit(unittest.TestCase):
self.assertTrue('From: portal@plone.test' in msg)
# We expect the headers to be properly header encoded (7-bit):
self.assertTrue(
'Subject: =?utf-8?q?A_comment_has_been_posted=2E?=\n'
'Subject: =?utf-8?q?A_comment_has_been_posted=2E?='
in msg)
# The output should be encoded in a reasonable manner
# (in this case quoted-printable):