From 13917821702b557aaa2f285ebbd6b2f79e1378ad 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 05:37:18 -0500 Subject: [PATCH] chore: use gapic-generator-python 0.58.4 (#86) 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 --- .../service_manager/transports/base.py | 1 - .../test_service_manager.py | 201 +++++++----------- 2 files changed, 77 insertions(+), 125 deletions(-) diff --git a/packages/google-cloud-service-management/google/cloud/servicemanagement_v1/services/service_manager/transports/base.py b/packages/google-cloud-service-management/google/cloud/servicemanagement_v1/services/service_manager/transports/base.py index 855586198692..8e0455cba7f6 100644 --- a/packages/google-cloud-service-management/google/cloud/servicemanagement_v1/services/service_manager/transports/base.py +++ b/packages/google-cloud-service-management/google/cloud/servicemanagement_v1/services/service_manager/transports/base.py @@ -110,7 +110,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-management/tests/unit/gapic/servicemanagement_v1/test_service_manager.py b/packages/google-cloud-service-management/tests/unit/gapic/servicemanagement_v1/test_service_manager.py index 70070e0c584d..87f151fc6551 100644 --- a/packages/google-cloud-service-management/tests/unit/gapic/servicemanagement_v1/test_service_manager.py +++ b/packages/google-cloud-service-management/tests/unit/gapic/servicemanagement_v1/test_service_manager.py @@ -282,20 +282,20 @@ def test_service_manager_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, @@ -354,7 +354,7 @@ def test_service_manager_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 @@ -449,7 +449,7 @@ def test_service_manager_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, @@ -480,7 +480,7 @@ def test_service_manager_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", @@ -513,9 +513,8 @@ def test_service_manager_client_client_options_from_dict(): ) -def test_list_services( - transport: str = "grpc", request_type=servicemanager.ListServicesRequest -): +@pytest.mark.parametrize("request_type", [servicemanager.ListServicesRequest, dict,]) +def test_list_services(request_type, transport: str = "grpc"): client = ServiceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -542,10 +541,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. @@ -686,8 +681,10 @@ async def test_list_services_flattened_error_async(): ) -def test_list_services_pager(): - client = ServiceManagerClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_services_pager(transport_name: str = "grpc"): + client = ServiceManagerClient( + 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: @@ -721,8 +718,10 @@ def test_list_services_pager(): assert all(isinstance(i, resources.ManagedService) for i in results) -def test_list_services_pages(): - client = ServiceManagerClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_services_pages(transport_name: str = "grpc"): + client = ServiceManagerClient( + 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: @@ -821,9 +820,8 @@ async def test_list_services_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_service( - transport: str = "grpc", request_type=servicemanager.GetServiceRequest -): +@pytest.mark.parametrize("request_type", [servicemanager.GetServiceRequest, dict,]) +def test_get_service(request_type, transport: str = "grpc"): client = ServiceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -852,10 +850,6 @@ def test_get_service( assert response.producer_project_id == "producer_project_id_value" -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. @@ -982,9 +976,8 @@ async def test_get_service_flattened_error_async(): ) -def test_create_service( - transport: str = "grpc", request_type=servicemanager.CreateServiceRequest -): +@pytest.mark.parametrize("request_type", [servicemanager.CreateServiceRequest, dict,]) +def test_create_service(request_type, transport: str = "grpc"): client = ServiceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1008,10 +1001,6 @@ def test_create_service( assert isinstance(response, future.Future) -def test_create_service_from_dict(): - test_create_service(request_type=dict) - - def test_create_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. @@ -1139,9 +1128,8 @@ async def test_create_service_flattened_error_async(): ) -def test_delete_service( - transport: str = "grpc", request_type=servicemanager.DeleteServiceRequest -): +@pytest.mark.parametrize("request_type", [servicemanager.DeleteServiceRequest, dict,]) +def test_delete_service(request_type, transport: str = "grpc"): client = ServiceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1165,10 +1153,6 @@ def test_delete_service( assert isinstance(response, future.Future) -def test_delete_service_from_dict(): - test_delete_service(request_type=dict) - - def test_delete_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. @@ -1290,9 +1274,8 @@ async def test_delete_service_flattened_error_async(): ) -def test_undelete_service( - transport: str = "grpc", request_type=servicemanager.UndeleteServiceRequest -): +@pytest.mark.parametrize("request_type", [servicemanager.UndeleteServiceRequest, dict,]) +def test_undelete_service(request_type, transport: str = "grpc"): client = ServiceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1316,10 +1299,6 @@ def test_undelete_service( assert isinstance(response, future.Future) -def test_undelete_service_from_dict(): - test_undelete_service(request_type=dict) - - def test_undelete_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. @@ -1441,9 +1420,10 @@ async def test_undelete_service_flattened_error_async(): ) -def test_list_service_configs( - transport: str = "grpc", request_type=servicemanager.ListServiceConfigsRequest -): +@pytest.mark.parametrize( + "request_type", [servicemanager.ListServiceConfigsRequest, dict,] +) +def test_list_service_configs(request_type, transport: str = "grpc"): client = ServiceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1472,10 +1452,6 @@ def test_list_service_configs( assert response.next_page_token == "next_page_token_value" -def test_list_service_configs_from_dict(): - test_list_service_configs(request_type=dict) - - def test_list_service_configs_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. @@ -1611,8 +1587,10 @@ async def test_list_service_configs_flattened_error_async(): ) -def test_list_service_configs_pager(): - client = ServiceManagerClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_service_configs_pager(transport_name: str = "grpc"): + client = ServiceManagerClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1650,8 +1628,10 @@ def test_list_service_configs_pager(): assert all(isinstance(i, service_pb2.Service) for i in results) -def test_list_service_configs_pages(): - client = ServiceManagerClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_service_configs_pages(transport_name: str = "grpc"): + client = ServiceManagerClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1762,9 +1742,10 @@ async def test_list_service_configs_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_service_config( - transport: str = "grpc", request_type=servicemanager.GetServiceConfigRequest -): +@pytest.mark.parametrize( + "request_type", [servicemanager.GetServiceConfigRequest, dict,] +) +def test_get_service_config(request_type, transport: str = "grpc"): client = ServiceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1799,10 +1780,6 @@ def test_get_service_config( assert response.id == "id_value" -def test_get_service_config_from_dict(): - test_get_service_config(request_type=dict) - - def test_get_service_config_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. @@ -1965,9 +1942,10 @@ async def test_get_service_config_flattened_error_async(): ) -def test_create_service_config( - transport: str = "grpc", request_type=servicemanager.CreateServiceConfigRequest -): +@pytest.mark.parametrize( + "request_type", [servicemanager.CreateServiceConfigRequest, dict,] +) +def test_create_service_config(request_type, transport: str = "grpc"): client = ServiceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2002,10 +1980,6 @@ def test_create_service_config( assert response.id == "id_value" -def test_create_service_config_from_dict(): - test_create_service_config(request_type=dict) - - def test_create_service_config_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. @@ -2159,9 +2133,10 @@ async def test_create_service_config_flattened_error_async(): ) -def test_submit_config_source( - transport: str = "grpc", request_type=servicemanager.SubmitConfigSourceRequest -): +@pytest.mark.parametrize( + "request_type", [servicemanager.SubmitConfigSourceRequest, dict,] +) +def test_submit_config_source(request_type, transport: str = "grpc"): client = ServiceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2187,10 +2162,6 @@ def test_submit_config_source( assert isinstance(response, future.Future) -def test_submit_config_source_from_dict(): - test_submit_config_source(request_type=dict) - - def test_submit_config_source_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. @@ -2347,9 +2318,10 @@ async def test_submit_config_source_flattened_error_async(): ) -def test_list_service_rollouts( - transport: str = "grpc", request_type=servicemanager.ListServiceRolloutsRequest -): +@pytest.mark.parametrize( + "request_type", [servicemanager.ListServiceRolloutsRequest, dict,] +) +def test_list_service_rollouts(request_type, transport: str = "grpc"): client = ServiceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2378,10 +2350,6 @@ def test_list_service_rollouts( assert response.next_page_token == "next_page_token_value" -def test_list_service_rollouts_from_dict(): - test_list_service_rollouts(request_type=dict) - - def test_list_service_rollouts_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. @@ -2529,8 +2497,10 @@ async def test_list_service_rollouts_flattened_error_async(): ) -def test_list_service_rollouts_pager(): - client = ServiceManagerClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_service_rollouts_pager(transport_name: str = "grpc"): + client = ServiceManagerClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2568,8 +2538,10 @@ def test_list_service_rollouts_pager(): assert all(isinstance(i, resources.Rollout) for i in results) -def test_list_service_rollouts_pages(): - client = ServiceManagerClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_service_rollouts_pages(transport_name: str = "grpc"): + client = ServiceManagerClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2680,9 +2652,10 @@ async def test_list_service_rollouts_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_service_rollout( - transport: str = "grpc", request_type=servicemanager.GetServiceRolloutRequest -): +@pytest.mark.parametrize( + "request_type", [servicemanager.GetServiceRolloutRequest, dict,] +) +def test_get_service_rollout(request_type, transport: str = "grpc"): client = ServiceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2720,10 +2693,6 @@ def test_get_service_rollout( assert response.service_name == "service_name_value" -def test_get_service_rollout_from_dict(): - test_get_service_rollout(request_type=dict) - - def test_get_service_rollout_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. @@ -2875,9 +2844,10 @@ async def test_get_service_rollout_flattened_error_async(): ) -def test_create_service_rollout( - transport: str = "grpc", request_type=servicemanager.CreateServiceRolloutRequest -): +@pytest.mark.parametrize( + "request_type", [servicemanager.CreateServiceRolloutRequest, dict,] +) +def test_create_service_rollout(request_type, transport: str = "grpc"): client = ServiceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2903,10 +2873,6 @@ def test_create_service_rollout( assert isinstance(response, future.Future) -def test_create_service_rollout_from_dict(): - test_create_service_rollout(request_type=dict) - - def test_create_service_rollout_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. @@ -3053,9 +3019,10 @@ async def test_create_service_rollout_flattened_error_async(): ) -def test_generate_config_report( - transport: str = "grpc", request_type=servicemanager.GenerateConfigReportRequest -): +@pytest.mark.parametrize( + "request_type", [servicemanager.GenerateConfigReportRequest, dict,] +) +def test_generate_config_report(request_type, transport: str = "grpc"): client = ServiceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3085,10 +3052,6 @@ def test_generate_config_report( assert response.id == "id_value" -def test_generate_config_report_from_dict(): - test_generate_config_report(request_type=dict) - - def test_generate_config_report_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. @@ -3239,9 +3202,8 @@ async def test_generate_config_report_flattened_error_async(): ) -def test_enable_service( - transport: str = "grpc", request_type=servicemanager.EnableServiceRequest -): +@pytest.mark.parametrize("request_type", [servicemanager.EnableServiceRequest, dict,]) +def test_enable_service(request_type, transport: str = "grpc"): client = ServiceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3265,10 +3227,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. @@ -3404,9 +3362,8 @@ async def test_enable_service_flattened_error_async(): ) -def test_disable_service( - transport: str = "grpc", request_type=servicemanager.DisableServiceRequest -): +@pytest.mark.parametrize("request_type", [servicemanager.DisableServiceRequest, dict,]) +def test_disable_service(request_type, transport: str = "grpc"): client = ServiceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3430,10 +3387,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. @@ -4124,7 +4077,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(