From 8bb406849475d753fbcacca13573377ee94ed1ab Mon Sep 17 00:00:00 2001 From: Victor Mota Date: Tue, 17 Dec 2019 14:52:55 -0800 Subject: [PATCH] fix(automl): fix TypeError when passing a client_info to automl TablesClient (#9949) * fix(automl): fix TypeError when passing a client_info to automl TablesClient The solution is to delete client_info from kwargs instead and pass named parameter. --- .../cloud/automl_v1beta1/tables/tables_client.py | 1 + .../unit/gapic/v1beta1/test_tables_client_v1beta1.py | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/automl/google/cloud/automl_v1beta1/tables/tables_client.py b/automl/google/cloud/automl_v1beta1/tables/tables_client.py index 668e1e55cbe5..eb382c3ee35e 100644 --- a/automl/google/cloud/automl_v1beta1/tables/tables_client.py +++ b/automl/google/cloud/automl_v1beta1/tables/tables_client.py @@ -104,6 +104,7 @@ def __init__( else: client_info_.user_agent = user_agent client_info_.gapic_version = version + kwargs.pop("client_info", None) if client is None: self.auto_ml_client = gapic.auto_ml_client.AutoMlClient( diff --git a/automl/tests/unit/gapic/v1beta1/test_tables_client_v1beta1.py b/automl/tests/unit/gapic/v1beta1/test_tables_client_v1beta1.py index 3f2b6d3de2bd..ce513083d19c 100644 --- a/automl/tests/unit/gapic/v1beta1/test_tables_client_v1beta1.py +++ b/automl/tests/unit/gapic/v1beta1/test_tables_client_v1beta1.py @@ -1424,3 +1424,14 @@ def test_prediction_client_credentials(self): _, prediction_client_kwargs = MockPredictionClient.call_args assert "credentials" in prediction_client_kwargs assert prediction_client_kwargs["credentials"] == credentials_mock + + def test_prediction_client_client_info(self): + client_info_mock = mock.Mock() + patch_prediction_client = mock.patch( + "google.cloud.automl_v1beta1.gapic.prediction_service_client.PredictionServiceClient" + ) + with patch_prediction_client as MockPredictionClient: + client = automl_v1beta1.TablesClient(client_info=client_info_mock) + _, prediction_client_kwargs = MockPredictionClient.call_args + assert "client_info" in prediction_client_kwargs + assert prediction_client_kwargs["client_info"] == client_info_mock