async def receive_result(self, rpc_message, return_path, options, bus_client: "BusClient"): if self.require_mocking: assert rpc_message.canonical_name in self.mock_responses, ( f"RPC {rpc_message.canonical_name} unexpectedly called. " f"Perhaps you need to use mockRpcCall() to ensure the mocker expects this call." ) if rpc_message.canonical_name in self.mock_responses: kwargs = self.mock_responses[rpc_message.canonical_name] return ResultMessage(**kwargs) else: return ResultMessage(result=None, rpc_message_id="1")
def test_result_validate(create_bus_client_with_unhappy_schema): client: BusClient = create_bus_client_with_unhappy_schema() message = ResultMessage(result="123", rpc_message_id="123") with pytest.raises(ValidationError): client._validate(message, direction="outgoing", api_name="api", procedure_name="proc") jsonschema.validate.assert_called_with("123", {})
async def receive_result(self, rpc_message, return_path, options): if self.require_mocking: assert rpc_message.canonical_name in self.mock_responses, ( f"RPC {rpc_message.canonical_name} unexpectedly called. " f"Perhaps you need to use mockRpcCall() to ensure the mocker expects this call." ) if rpc_message.canonical_name in self.mock_responses: kwargs = self.mock_responses[rpc_message.canonical_name].copy() kwargs.setdefault("api_name", rpc_message.api_name) kwargs.setdefault("procedure_name", rpc_message.procedure_name) kwargs.setdefault("rpc_message_id", rpc_message.id) return ResultMessage(**kwargs) else: return ResultMessage( result=None, rpc_message_id="1", api_name=rpc_message.api_name, procedure_name=rpc_message.procedure_name, )