Skip to content

Commit ccc7498

Browse files
authored
chore(automl): mock AutoMlClient in test_predicition_client_client_info (#18068)
Following #17616, `google-api-core` extracts and deduplicates the `x-goog-api-client` metrics header during callable construction in `_GapicCallable.__init__` (`_extract_metrics_header`). Because `AutoMlClient` was not mocked in this test, passing `client_info=mock.Mock()` caused `AutoMlClient`'s transport wrapper to attempt unpacking the mock metadata into `(key, value)` pairs, resulting in: ```text TypeError: cannot unpack non-iterable Mock object
1 parent bd979a6 commit ccc7498

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

packages/google-cloud-automl/tests/unit/test_tables_client_v1beta1.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1716,12 +1716,14 @@ def test_prediction_client_credentials(self):
17161716
def test_prediction_client_client_info(self):
17171717
credentials_mock = mock.Mock()
17181718
client_info_mock = mock.Mock()
1719+
client_mock = mock.Mock()
17191720
patch_prediction_client = mock.patch(
17201721
"google.cloud.automl_v1beta1.services.tables.tables_client.PredictionServiceClient"
17211722
)
17221723
with patch_prediction_client as MockPredictionClient:
17231724
automl_v1beta1.TablesClient(
17241725
credentials=credentials_mock,
1726+
client=client_mock,
17251727
client_info=client_info_mock,
17261728
)
17271729
_, prediction_client_kwargs = MockPredictionClient.call_args

0 commit comments

Comments
 (0)