From 761c5cd41d9fde118dc8caa9366e32e9d7bbee22 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Tue, 11 Jan 2022 14:10:24 -0500 Subject: [PATCH] chore: use gapic-generator-python 0.58.4 (#9) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: use gapic-generator-python 0.58.4 fix: provide appropriate mock values for message body fields committer: dovs PiperOrigin-RevId: 419025932 Source-Link: https://github.com/googleapis/googleapis/commit/73da6697f598f1ba30618924936a59f8e457ec89 Source-Link: https://github.com/googleapis/googleapis-gen/commit/46df624a54b9ed47c1a7eefb7a49413cf7b82f98 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNDZkZjYyNGE1NGI5ZWQ0N2MxYTdlZWZiN2E0OTQxM2NmN2I4MmY5OCJ9 * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot Co-authored-by: Anthonios Partheniou --- .../ids_v1/services/ids/transports/base.py | 1 - .../tests/unit/gapic/ids_v1/test_ids.py | 58 ++++++++----------- 2 files changed, 23 insertions(+), 36 deletions(-) diff --git a/packages/google-cloud-ids/google/cloud/ids_v1/services/ids/transports/base.py b/packages/google-cloud-ids/google/cloud/ids_v1/services/ids/transports/base.py index b98283f45255..4384f2403aa3 100644 --- a/packages/google-cloud-ids/google/cloud/ids_v1/services/ids/transports/base.py +++ b/packages/google-cloud-ids/google/cloud/ids_v1/services/ids/transports/base.py @@ -101,7 +101,6 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id diff --git a/packages/google-cloud-ids/tests/unit/gapic/ids_v1/test_ids.py b/packages/google-cloud-ids/tests/unit/gapic/ids_v1/test_ids.py index ffd2b1660227..a56e8aa75605 100644 --- a/packages/google-cloud-ids/tests/unit/gapic/ids_v1/test_ids.py +++ b/packages/google-cloud-ids/tests/unit/gapic/ids_v1/test_ids.py @@ -224,20 +224,20 @@ def test_ids_client_client_options(client_class, transport_class, transport_name # unsupported value. with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): with pytest.raises(MutualTLSChannelError): - client = client_class() + client = client_class(transport=transport_name) # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. with mock.patch.dict( os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"} ): with pytest.raises(ValueError): - client = client_class() + client = client_class(transport=transport_name) # Check the case quota_project_id is provided options = client_options.ClientOptions(quota_project_id="octopus") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -280,7 +280,7 @@ def test_ids_client_mtls_env_auto( ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) if use_client_cert_env == "false": expected_client_cert_source = None @@ -371,7 +371,7 @@ def test_ids_client_client_options_scopes( options = client_options.ClientOptions(scopes=["1", "2"],) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -398,7 +398,7 @@ def test_ids_client_client_options_credentials_file( options = client_options.ClientOptions(credentials_file="credentials.json") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file="credentials.json", @@ -429,7 +429,8 @@ def test_ids_client_client_options_from_dict(): ) -def test_list_endpoints(transport: str = "grpc", request_type=ids.ListEndpointsRequest): +@pytest.mark.parametrize("request_type", [ids.ListEndpointsRequest, dict,]) +def test_list_endpoints(request_type, transport: str = "grpc"): client = IDSClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -457,10 +458,6 @@ def test_list_endpoints(transport: str = "grpc", request_type=ids.ListEndpointsR assert response.unreachable == ["unreachable_value"] -def test_list_endpoints_from_dict(): - test_list_endpoints(request_type=dict) - - def test_list_endpoints_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -634,8 +631,10 @@ async def test_list_endpoints_flattened_error_async(): ) -def test_list_endpoints_pager(): - client = IDSClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_endpoints_pager(transport_name: str = "grpc"): + client = IDSClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_endpoints), "__call__") as call: @@ -666,8 +665,10 @@ def test_list_endpoints_pager(): assert all(isinstance(i, ids.Endpoint) for i in results) -def test_list_endpoints_pages(): - client = IDSClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_endpoints_pages(transport_name: str = "grpc"): + client = IDSClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_endpoints), "__call__") as call: @@ -748,7 +749,8 @@ async def test_list_endpoints_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_endpoint(transport: str = "grpc", request_type=ids.GetEndpointRequest): +@pytest.mark.parametrize("request_type", [ids.GetEndpointRequest, dict,]) +def test_get_endpoint(request_type, transport: str = "grpc"): client = IDSClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -789,10 +791,6 @@ def test_get_endpoint(transport: str = "grpc", request_type=ids.GetEndpointReque assert response.traffic_logs is True -def test_get_endpoint_from_dict(): - test_get_endpoint(request_type=dict) - - def test_get_endpoint_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -974,9 +972,8 @@ async def test_get_endpoint_flattened_error_async(): ) -def test_create_endpoint( - transport: str = "grpc", request_type=ids.CreateEndpointRequest -): +@pytest.mark.parametrize("request_type", [ids.CreateEndpointRequest, dict,]) +def test_create_endpoint(request_type, transport: str = "grpc"): client = IDSClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1000,10 +997,6 @@ def test_create_endpoint( assert isinstance(response, future.Future) -def test_create_endpoint_from_dict(): - test_create_endpoint(request_type=dict) - - def test_create_endpoint_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -1198,9 +1191,8 @@ async def test_create_endpoint_flattened_error_async(): ) -def test_delete_endpoint( - transport: str = "grpc", request_type=ids.DeleteEndpointRequest -): +@pytest.mark.parametrize("request_type", [ids.DeleteEndpointRequest, dict,]) +def test_delete_endpoint(request_type, transport: str = "grpc"): client = IDSClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1224,10 +1216,6 @@ def test_delete_endpoint( assert isinstance(response, future.Future) -def test_delete_endpoint_from_dict(): - test_delete_endpoint(request_type=dict) - - def test_delete_endpoint_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -1918,7 +1906,7 @@ def test_parse_common_location_path(): assert expected == actual -def test_client_withDEFAULT_CLIENT_INFO(): +def test_client_with_default_client_info(): client_info = gapic_v1.client_info.ClientInfo() with mock.patch.object(transports.IDSTransport, "_prep_wrapped_messages") as prep: