From 5f509bf2e58b9e82121d34197340e8674af1c7d8 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Sat, 8 Jan 2022 06:58:45 -0500 Subject: [PATCH] chore: use gapic-generator-python 0.58.4 (#69) 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 --- .../services/service_usage/transports/base.py | 1 - .../service_usage_v1/test_service_usage.py | 82 +++++++------------ 2 files changed, 29 insertions(+), 54 deletions(-) diff --git a/packages/google-cloud-service-usage/google/cloud/service_usage_v1/services/service_usage/transports/base.py b/packages/google-cloud-service-usage/google/cloud/service_usage_v1/services/service_usage/transports/base.py index b3f797f2aff2..f8712ec1e9ce 100644 --- a/packages/google-cloud-service-usage/google/cloud/service_usage_v1/services/service_usage/transports/base.py +++ b/packages/google-cloud-service-usage/google/cloud/service_usage_v1/services/service_usage/transports/base.py @@ -108,7 +108,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-service-usage/tests/unit/gapic/service_usage_v1/test_service_usage.py b/packages/google-cloud-service-usage/tests/unit/gapic/service_usage_v1/test_service_usage.py index 2b79e01b8b92..e6c6dace679c 100644 --- a/packages/google-cloud-service-usage/tests/unit/gapic/service_usage_v1/test_service_usage.py +++ b/packages/google-cloud-service-usage/tests/unit/gapic/service_usage_v1/test_service_usage.py @@ -242,20 +242,20 @@ def test_service_usage_client_client_options( # 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, @@ -312,7 +312,7 @@ def test_service_usage_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 @@ -407,7 +407,7 @@ def test_service_usage_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, @@ -438,7 +438,7 @@ def test_service_usage_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", @@ -469,9 +469,8 @@ def test_service_usage_client_client_options_from_dict(): ) -def test_enable_service( - transport: str = "grpc", request_type=serviceusage.EnableServiceRequest -): +@pytest.mark.parametrize("request_type", [serviceusage.EnableServiceRequest, dict,]) +def test_enable_service(request_type, transport: str = "grpc"): client = ServiceUsageClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -495,10 +494,6 @@ def test_enable_service( assert isinstance(response, future.Future) -def test_enable_service_from_dict(): - test_enable_service(request_type=dict) - - def test_enable_service_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. @@ -599,9 +594,8 @@ async def test_enable_service_field_headers_async(): assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] -def test_disable_service( - transport: str = "grpc", request_type=serviceusage.DisableServiceRequest -): +@pytest.mark.parametrize("request_type", [serviceusage.DisableServiceRequest, dict,]) +def test_disable_service(request_type, transport: str = "grpc"): client = ServiceUsageClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -625,10 +619,6 @@ def test_disable_service( assert isinstance(response, future.Future) -def test_disable_service_from_dict(): - test_disable_service(request_type=dict) - - def test_disable_service_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. @@ -729,9 +719,8 @@ async def test_disable_service_field_headers_async(): assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] -def test_get_service( - transport: str = "grpc", request_type=serviceusage.GetServiceRequest -): +@pytest.mark.parametrize("request_type", [serviceusage.GetServiceRequest, dict,]) +def test_get_service(request_type, transport: str = "grpc"): client = ServiceUsageClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -760,10 +749,6 @@ def test_get_service( assert response.state == resources.State.DISABLED -def test_get_service_from_dict(): - test_get_service(request_type=dict) - - def test_get_service_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. @@ -869,9 +854,8 @@ async def test_get_service_field_headers_async(): assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] -def test_list_services( - transport: str = "grpc", request_type=serviceusage.ListServicesRequest -): +@pytest.mark.parametrize("request_type", [serviceusage.ListServicesRequest, dict,]) +def test_list_services(request_type, transport: str = "grpc"): client = ServiceUsageClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -898,10 +882,6 @@ def test_list_services( assert response.next_page_token == "next_page_token_value" -def test_list_services_from_dict(): - test_list_services(request_type=dict) - - def test_list_services_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. @@ -1003,8 +983,10 @@ async def test_list_services_field_headers_async(): assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] -def test_list_services_pager(): - client = ServiceUsageClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_services_pager(transport_name: str = "grpc"): + client = ServiceUsageClient( + 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_services), "__call__") as call: @@ -1041,8 +1023,10 @@ def test_list_services_pager(): assert all(isinstance(i, resources.Service) for i in results) -def test_list_services_pages(): - client = ServiceUsageClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_services_pages(transport_name: str = "grpc"): + client = ServiceUsageClient( + 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_services), "__call__") as call: @@ -1141,9 +1125,10 @@ async def test_list_services_async_pages(): assert page_.raw_page.next_page_token == token -def test_batch_enable_services( - transport: str = "grpc", request_type=serviceusage.BatchEnableServicesRequest -): +@pytest.mark.parametrize( + "request_type", [serviceusage.BatchEnableServicesRequest, dict,] +) +def test_batch_enable_services(request_type, transport: str = "grpc"): client = ServiceUsageClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1169,10 +1154,6 @@ def test_batch_enable_services( assert isinstance(response, future.Future) -def test_batch_enable_services_from_dict(): - test_batch_enable_services(request_type=dict) - - def test_batch_enable_services_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. @@ -1282,9 +1263,8 @@ async def test_batch_enable_services_field_headers_async(): assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] -def test_batch_get_services( - transport: str = "grpc", request_type=serviceusage.BatchGetServicesRequest -): +@pytest.mark.parametrize("request_type", [serviceusage.BatchGetServicesRequest, dict,]) +def test_batch_get_services(request_type, transport: str = "grpc"): client = ServiceUsageClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1310,10 +1290,6 @@ def test_batch_get_services( assert isinstance(response, serviceusage.BatchGetServicesResponse) -def test_batch_get_services_from_dict(): - test_batch_get_services(request_type=dict) - - def test_batch_get_services_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. @@ -1953,7 +1929,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(