def test_handle_request(self, call_function_mock): call_function_mock.return_value = {"output": 1} m = Method("test_description") m.set_logger_name("mname") request = Mock( id=(123, Mock()), type="Post", parameters={"first": 2}, respond_with_return=Mock()) response = m.get_response(request) call_function_mock.assert_called_with({"first": 2}) self.assertEquals({"output": 1}, response.value)
def test_handle_request(self, call_function_mock): call_function_mock.return_value = {"output": 1} m = Method("test_description") m.set_logger_name("mname") request = Mock(id=(123, Mock()), type="Post", parameters={"first": 2}, respond_with_return=Mock()) response = m.get_response(request) call_function_mock.assert_called_with({"first": 2}) self.assertEquals({"output": 1}, response.value)
def test_get_response_no_parameters(self): m = Method("test_description") m.set_logger_name("mname") call_func_mock = MagicMock() m.call_function = call_func_mock func = Mock(return_value={"first_out": "test"}) m.set_function(func) args_meta = Mock(spec=MapMeta) args_meta.elements = {"first": Mock()} m.set_takes(args_meta) request = MagicMock() del request.parameters # Make sure mock doesn't have `parameters` m.get_response(request) call_func_mock.assert_called_once_with(dict())