Commit a31abf5b authored by Jérome Perrin's avatar Jérome Perrin

crm: make check_consistency argument of sendMessage false by default

This is for backward compatibility.

Also add some explicit tests for check_consistency, it was missing in
the first place.
parent d49e4ffd
......@@ -233,7 +233,7 @@ class NotificationTool(BaseTool):
attachment_list=None, attachment_document_list=None,
notifier_list=None, priority_level=None,
store_as_event=False,
check_consistency=True,
check_consistency=False,
message_text_format='text/plain',
event_keyword_argument_dict=None,
portal_type_list=None):
......
......@@ -369,7 +369,7 @@ class TestNotificationTool(ERP5TypeTestCase):
"""
Check that notification fails when the destination hasn't a email adress
"""
with self.assertRaises(ValueError):
with self.assertRaisesRegexp(ValueError, "email must be set"):
self.portal.portal_notifications.sendMessage(
recipient='userWithoutEmail', subject='Subject', message='Message')
......@@ -529,6 +529,24 @@ class TestNotificationToolWithCRM(TestNotificationTool):
self.assertEqual(person, event.getDestinationValue())
self.assertEqual('started', event.getSimulationState())
def test_check_consistency(self):
# This test only applies when erp5_crm is installed and we have
# a constraint on mail message
person_without_email = self.portal.person_module.newContent(
portal_type="Person",)
self.tic()
with self.assertRaises(ValueError) as exception_context:
self.portal.portal_notifications.sendMessage(
check_consistency=True,
recipient=person,
subject='Subject',
message='Message')
consistency_message_list, = exception_context.exception.args
consistency_message, = consistency_message_list
from Products.ERP5Type.ConsistencyMessage import ConsistencyMessage
self.assertIsInstance(consistency_message, ConsistencyMessage)
self.assertEqual('Recipients email must be defined', consistency_message.getTranslatedMessage())
def test_suite():
suite = unittest.TestSuite()
......
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