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

ERP5/NotificationTool: Raise ValueError when input data is invalid

parent bfa20420
...@@ -321,9 +321,7 @@ class NotificationTool(BaseTool): ...@@ -321,9 +321,7 @@ class NotificationTool(BaseTool):
person_value = catalog_tool.getResultValue(portal_type=portal_type_list, person_value = catalog_tool.getResultValue(portal_type=portal_type_list,
reference=person) reference=person)
if person_value is None: if person_value is None:
# For backward compatibility. I recommend to use ValueError.(yusei) raise ValueError("Can't find person document which reference is '%s'" % person)
raise IndexError, "Can't find person document which reference is '%s'" % person
else:
person = person_value person = person_value
to_person_list.append(person) to_person_list.append(person)
......
...@@ -384,11 +384,9 @@ class TestNotificationTool(ERP5TypeTestCase): ...@@ -384,11 +384,9 @@ class TestNotificationTool(ERP5TypeTestCase):
sequence_list.play(self) sequence_list.play(self)
def test_09_InvalideRecipient(self): def test_09_InvalideRecipient(self):
self.assertRaises( with self.assertRaises(ValueError):
IndexError, self.portal.portal_notifications.sendMessage(
self.portal.portal_notifications.sendMessage, recipient='UnknowUser', subject='Subject', message='Message')
recipient='UnknowUser', subject='Subject', message='Message'
)
def stepCheckPersonNotification(self, sequence=None, def stepCheckPersonNotification(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
......
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