Provide kwargs for callback abort

The callback mechanism allows notifiers to provide keyword args in
the notification. If this is a create callback, and there is an
exception, then the notifier will call an abort callback.

However, currently, the keyword arguments are not provided to the
abort callback. This information could be useful for the callbacks,
and would make the mechanism consistent. This commit provides that
information.

Change-Id: I2ee0363b52f9de5fcd72905957e8f7e7796f630e
This commit is contained in:
Paul Michali 2016-01-12 21:44:47 +00:00
parent bf67c6f3cf
commit 8771ab4816
2 changed files with 7 additions and 4 deletions

View File

@ -119,7 +119,7 @@ class CallbacksManager(object):
if errors and event.startswith(events.BEFORE):
abort_event = event.replace(
events.BEFORE, events.ABORT)
self._notify_loop(resource, abort_event, trigger)
self._notify_loop(resource, abort_event, trigger, **kwargs)
raise exceptions.CallbackFailure(errors=errors)
def clear(self):

View File

@ -149,10 +149,13 @@ class CallBacksManagerTestCase(base.BaseTestCase):
n.return_value = ['error']
self.assertRaises(exceptions.CallbackFailure,
self.manager.notify,
mock.ANY, events.BEFORE_CREATE, mock.ANY)
mock.ANY, events.BEFORE_CREATE,
'trigger', params={'a': 1})
expected_calls = [
mock.call(mock.ANY, 'before_create', mock.ANY),
mock.call(mock.ANY, 'abort_create', mock.ANY)
mock.call(mock.ANY, 'before_create',
'trigger', params={'a': 1}),
mock.call(mock.ANY, 'abort_create',
'trigger', params={'a': 1})
]
n.assert_has_calls(expected_calls)