def test_predict(self): # Setup Expected Response expected_response = {} expected_response = prediction_service_pb2.PredictResponse(**expected_response) # Mock the API response channel = ChannelStub(responses=[expected_response]) patch = mock.patch("google.api_core.grpc_helpers.create_channel") with patch as create_channel: create_channel.return_value = channel client = automl_v1beta1.PredictionServiceClient() # Setup Request name = client.model_path("[PROJECT]", "[LOCATION]", "[MODEL]") payload = {} response = client.predict(name, payload) assert expected_response == response assert len(channel.requests) == 1 expected_request = prediction_service_pb2.PredictRequest( name=name, payload=payload ) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_predict(self): # Setup Expected Response expected_response = {} expected_response = prediction_service_pb2.PredictResponse( **expected_response) # Mock the API response channel = ChannelStub(responses=[expected_response]) client = automl_v1beta1.PredictionServiceClient(channel=channel) # Setup Request name = client.model_path('[PROJECT]', '[LOCATION]', '[MODEL]') payload = {} response = client.predict(name, payload) assert expected_response == response assert len(channel.requests) == 1 expected_request = prediction_service_pb2.PredictRequest( name=name, payload=payload) actual_request = channel.requests[0][1] assert expected_request == actual_request