Commit 8cb8d15c by Jérome Perrin

ERP5/NotificationTool: Raise ValueError when input data is invalid

1 parent 5e7ad3b7
......@@ -321,10 +321,8 @@ class NotificationTool(BaseTool):
person_value = catalog_tool.getResultValue(portal_type=portal_type_list,
reference=person)
if person_value is None:
# For backward compatibility. I recommend to use ValueError.(yusei)
raise IndexError, "Can't find person document which reference is '%s'" % person
else:
person = person_value
raise ValueError("Can't find person document which reference is '%s'" % person)
person = person_value
to_person_list.append(person)
# prepare low-level arguments if needed.
......
......@@ -384,11 +384,9 @@ class TestNotificationTool(ERP5TypeTestCase):
sequence_list.play(self)
def test_09_InvalideRecipient(self):
self.assertRaises(
IndexError,
self.portal.portal_notifications.sendMessage,
recipient='UnknowUser', subject='Subject', message='Message'
)
with self.assertRaises(ValueError):
self.portal.portal_notifications.sendMessage(
recipient='UnknowUser', subject='Subject', message='Message')
def stepCheckPersonNotification(self, sequence=None,
sequence_list=None, **kw):
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!