def test_invoke(self): my_formatter = mock.Mock() write_hooks.register("my_writer")(my_formatter) write_hooks._invoke("my_writer", "/some/path", {"option": 1}) my_formatter.assert_called_once_with("/some/path", {"option": 1})
def test_generic(self): hook1 = mock.Mock() hook2 = mock.Mock() write_hooks.register("hook1")(hook1) write_hooks.register("hook2")(hook2) self.cfg = _no_sql_testing_config(directives=("\n[post_write_hooks]\n" "hooks=hook1,hook2\n" "hook1.type=hook1\n" "hook1.arg1=foo\n" "hook2.type=hook2\n" "hook2.arg1=bar\n")) rev = command.revision(self.cfg, message="x") eq_( hook1.mock_calls, [ mock.call( rev.path, { "type": "hook1", "arg1": "foo", "_hook_name": "hook1" }, ) ], ) eq_( hook2.mock_calls, [ mock.call( rev.path, { "type": "hook2", "arg1": "bar", "_hook_name": "hook2" }, ) ], )