Commit 0d34c03a authored by Jérome Perrin's avatar Jérome Perrin

CRM: test we send only one email

parent 33d27b15
...@@ -1030,7 +1030,7 @@ class TestCRMMailSend(BaseTestCRM): ...@@ -1030,7 +1030,7 @@ class TestCRMMailSend(BaseTestCRM):
event.setTextContent(text_content) event.setTextContent(text_content)
self.portal.portal_workflow.doActionFor(event, 'start_action') self.portal.portal_workflow.doActionFor(event, 'start_action')
self.tic() self.tic()
last_message = self.portal.MailHost._last_message last_message, = self.portal.MailHost._message_list
self.assertNotEquals((), last_message) self.assertNotEquals((), last_message)
mfrom, mto, messageText = last_message mfrom, mto, messageText = last_message
self.assertEquals('"Me," <me@erp5.org>', mfrom) self.assertEquals('"Me," <me@erp5.org>', mfrom)
...@@ -1097,6 +1097,7 @@ class TestCRMMailSend(BaseTestCRM): ...@@ -1097,6 +1097,7 @@ class TestCRMMailSend(BaseTestCRM):
self.tic() self.tic()
# this means no message have been set # this means no message have been set
self.assertEquals([], self.portal.MailHost._message_list)
self.assertEquals((), self.portal.MailHost._last_message) self.assertEquals((), self.portal.MailHost._last_message)
def test_MailMessageHTML(self): def test_MailMessageHTML(self):
...@@ -1786,21 +1787,23 @@ class TestCRMMailSend(BaseTestCRM): ...@@ -1786,21 +1787,23 @@ class TestCRMMailSend(BaseTestCRM):
last_message_date = DateTime(message.get("Date")) last_message_date = DateTime(message.get("Date"))
self.assertTrue(last_message_date.isCurrentDay()) self.assertTrue(last_message_date.isCurrentDay())
def test_MailMessage_Event_send_simple_case(self): def test_MailMessage_send_simple_case(self):
""" """
Check that the script Event_send send one email passing all parameters directly Check that the method send send one email passing all parameters directly
from_url, to_url, reply_url, subject, body, attachment_format, attachment_list from_url, to_url, reply_url, subject, body, attachment_format, attachment_list
""" """
mail_message = self.portal.event_module.newContent(portal_type="Mail Message") mail_message = self.portal.event_module.newContent(portal_type="Mail Message")
self.tic() self.tic()
mail_message.Event_send(from_url='FG ER <eee@eee.com>', mail_message.send(from_url='FG ER <eee@eee.com>',
to_url='Expert User <expert@in24.test>', to_url='Expert User <expert@in24.test>',
subject="Simple Case", subject="Simple Case",
body="Body Simple Case", body="Body Simple Case",
attachment_list=[]) attachment_list=[])
self.tic() self.tic()
last_message = self.portal.MailHost._last_message[-1] (from_url, to_url, last_message,), = self.portal.MailHost._message_list
self.assertTrue("Body Simple Case" in last_message) self.assertTrue("Body Simple Case" in last_message)
self.assertEquals('FG ER <eee@eee.com>', from_url)
self.assertEquals(['Expert User <expert@in24.test>'], to_url)
def test_suite(): def test_suite():
......
...@@ -125,6 +125,7 @@ class TestNotificationTool(ERP5TypeTestCase): ...@@ -125,6 +125,7 @@ class TestNotificationTool(ERP5TypeTestCase):
if 'MailHost' in portal.objectIds(): if 'MailHost' in portal.objectIds():
portal.manage_delObjects(['MailHost']) portal.manage_delObjects(['MailHost'])
portal._setObject('MailHost', DummyMailHost('MailHost')) portal._setObject('MailHost', DummyMailHost('MailHost'))
self.portal.MailHost.reset()
portal.email_from_address = 'site@example.invalid' portal.email_from_address = 'site@example.invalid'
self.portal.portal_caches.clearAllCache() self.portal.portal_caches.clearAllCache()
self.tic() self.tic()
...@@ -464,8 +465,7 @@ Yes, I will go.""" ...@@ -464,8 +465,7 @@ Yes, I will go."""
self.portal.portal_notifications.sendMessage( self.portal.portal_notifications.sendMessage(
recipient='userA', subject='Subject', recipient='userA', subject='Subject',
message_text_format='text/html', message=message) message_text_format='text/html', message=message)
last_message = self.portal.MailHost._last_message last_message, = self.portal.MailHost._message_list
self.assertNotEquals((), last_message)
mfrom, mto, messageText = last_message mfrom, mto, messageText = last_message
self.assertEquals('Portal Administrator <site@example.invalid>', mfrom) self.assertEquals('Portal Administrator <site@example.invalid>', mfrom)
self.assertEquals(['userA@example.invalid'], mto) self.assertEquals(['userA@example.invalid'], mto)
...@@ -514,8 +514,7 @@ class TestNotificationToolWithCRM(TestNotificationTool): ...@@ -514,8 +514,7 @@ class TestNotificationToolWithCRM(TestNotificationTool):
subject='Subject', subject='Subject',
message='Message') message='Message')
self.tic() self.tic()
last_message = self.portal.MailHost._last_message last_message, = self.portal.MailHost._message_list
self.assertNotEquals((), last_message)
mfrom, mto, messageText = last_message mfrom, mto, messageText = last_message
mail_dict = decode_email(messageText) mail_dict = decode_email(messageText)
self.assertEquals('Portal Administrator <site@example.invalid>', mfrom) self.assertEquals('Portal Administrator <site@example.invalid>', mfrom)
......
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