From 3216dd9957c10614723710090ed80fc9e80a8b7d 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:07:16 -0500 Subject: [PATCH] chore: use gapic-generator-python 0.58.4 (#261) 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 --- .../data_transfer_service/transports/base.py | 1 - .../test_data_transfer_service.py | 200 +++++++----------- 2 files changed, 79 insertions(+), 122 deletions(-) diff --git a/google/cloud/bigquery_datatransfer_v1/services/data_transfer_service/transports/base.py b/google/cloud/bigquery_datatransfer_v1/services/data_transfer_service/transports/base.py index 2404f288..2d662a50 100644 --- a/google/cloud/bigquery_datatransfer_v1/services/data_transfer_service/transports/base.py +++ b/google/cloud/bigquery_datatransfer_v1/services/data_transfer_service/transports/base.py @@ -103,7 +103,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/tests/unit/gapic/bigquery_datatransfer_v1/test_data_transfer_service.py b/tests/unit/gapic/bigquery_datatransfer_v1/test_data_transfer_service.py index 266a46f1..4e76586a 100644 --- a/tests/unit/gapic/bigquery_datatransfer_v1/test_data_transfer_service.py +++ b/tests/unit/gapic/bigquery_datatransfer_v1/test_data_transfer_service.py @@ -263,20 +263,20 @@ def test_data_transfer_service_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, @@ -345,7 +345,7 @@ def test_data_transfer_service_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 @@ -444,7 +444,7 @@ def test_data_transfer_service_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, @@ -479,7 +479,7 @@ def test_data_transfer_service_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", @@ -512,9 +512,8 @@ def test_data_transfer_service_client_client_options_from_dict(): ) -def test_get_data_source( - transport: str = "grpc", request_type=datatransfer.GetDataSourceRequest -): +@pytest.mark.parametrize("request_type", [datatransfer.GetDataSourceRequest, dict,]) +def test_get_data_source(request_type, transport: str = "grpc"): client = DataTransferServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -577,10 +576,6 @@ def test_get_data_source( assert response.manual_runs_disabled is True -def test_get_data_source_from_dict(): - test_get_data_source(request_type=dict) - - def test_get_data_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. @@ -800,9 +795,8 @@ async def test_get_data_source_flattened_error_async(): ) -def test_list_data_sources( - transport: str = "grpc", request_type=datatransfer.ListDataSourcesRequest -): +@pytest.mark.parametrize("request_type", [datatransfer.ListDataSourcesRequest, dict,]) +def test_list_data_sources(request_type, transport: str = "grpc"): client = DataTransferServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -831,10 +825,6 @@ def test_list_data_sources( assert response.next_page_token == "next_page_token_value" -def test_list_data_sources_from_dict(): - test_list_data_sources(request_type=dict) - - def test_list_data_sources_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. @@ -1030,8 +1020,10 @@ async def test_list_data_sources_flattened_error_async(): ) -def test_list_data_sources_pager(): - client = DataTransferServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_data_sources_pager(transport_name: str = "grpc"): + client = DataTransferServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1072,8 +1064,10 @@ def test_list_data_sources_pager(): assert all(isinstance(i, datatransfer.DataSource) for i in results) -def test_list_data_sources_pages(): - client = DataTransferServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_data_sources_pages(transport_name: str = "grpc"): + client = DataTransferServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1188,9 +1182,10 @@ async def test_list_data_sources_async_pages(): assert page_.raw_page.next_page_token == token -def test_create_transfer_config( - transport: str = "grpc", request_type=datatransfer.CreateTransferConfigRequest -): +@pytest.mark.parametrize( + "request_type", [datatransfer.CreateTransferConfigRequest, dict,] +) +def test_create_transfer_config(request_type, transport: str = "grpc"): client = DataTransferServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1238,10 +1233,6 @@ def test_create_transfer_config( assert response.notification_pubsub_topic == "notification_pubsub_topic_value" -def test_create_transfer_config_from_dict(): - test_create_transfer_config(request_type=dict) - - def test_create_transfer_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. @@ -1472,9 +1463,10 @@ async def test_create_transfer_config_flattened_error_async(): ) -def test_update_transfer_config( - transport: str = "grpc", request_type=datatransfer.UpdateTransferConfigRequest -): +@pytest.mark.parametrize( + "request_type", [datatransfer.UpdateTransferConfigRequest, dict,] +) +def test_update_transfer_config(request_type, transport: str = "grpc"): client = DataTransferServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1522,10 +1514,6 @@ def test_update_transfer_config( assert response.notification_pubsub_topic == "notification_pubsub_topic_value" -def test_update_transfer_config_from_dict(): - test_update_transfer_config(request_type=dict) - - def test_update_transfer_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. @@ -1762,9 +1750,10 @@ async def test_update_transfer_config_flattened_error_async(): ) -def test_delete_transfer_config( - transport: str = "grpc", request_type=datatransfer.DeleteTransferConfigRequest -): +@pytest.mark.parametrize( + "request_type", [datatransfer.DeleteTransferConfigRequest, dict,] +) +def test_delete_transfer_config(request_type, transport: str = "grpc"): client = DataTransferServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1790,10 +1779,6 @@ def test_delete_transfer_config( assert response is None -def test_delete_transfer_config_from_dict(): - test_delete_transfer_config(request_type=dict) - - def test_delete_transfer_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. @@ -1981,9 +1966,8 @@ async def test_delete_transfer_config_flattened_error_async(): ) -def test_get_transfer_config( - transport: str = "grpc", request_type=datatransfer.GetTransferConfigRequest -): +@pytest.mark.parametrize("request_type", [datatransfer.GetTransferConfigRequest, dict,]) +def test_get_transfer_config(request_type, transport: str = "grpc"): client = DataTransferServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2031,10 +2015,6 @@ def test_get_transfer_config( assert response.notification_pubsub_topic == "notification_pubsub_topic_value" -def test_get_transfer_config_from_dict(): - test_get_transfer_config(request_type=dict) - - def test_get_transfer_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. @@ -2248,9 +2228,10 @@ async def test_get_transfer_config_flattened_error_async(): ) -def test_list_transfer_configs( - transport: str = "grpc", request_type=datatransfer.ListTransferConfigsRequest -): +@pytest.mark.parametrize( + "request_type", [datatransfer.ListTransferConfigsRequest, dict,] +) +def test_list_transfer_configs(request_type, transport: str = "grpc"): client = DataTransferServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2279,10 +2260,6 @@ def test_list_transfer_configs( assert response.next_page_token == "next_page_token_value" -def test_list_transfer_configs_from_dict(): - test_list_transfer_configs(request_type=dict) - - def test_list_transfer_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. @@ -2479,8 +2456,10 @@ async def test_list_transfer_configs_flattened_error_async(): ) -def test_list_transfer_configs_pager(): - client = DataTransferServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_transfer_configs_pager(transport_name: str = "grpc"): + client = DataTransferServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2524,8 +2503,10 @@ def test_list_transfer_configs_pager(): assert all(isinstance(i, transfer.TransferConfig) for i in results) -def test_list_transfer_configs_pages(): - client = DataTransferServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_transfer_configs_pages(transport_name: str = "grpc"): + client = DataTransferServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2649,9 +2630,10 @@ async def test_list_transfer_configs_async_pages(): assert page_.raw_page.next_page_token == token -def test_schedule_transfer_runs( - transport: str = "grpc", request_type=datatransfer.ScheduleTransferRunsRequest -): +@pytest.mark.parametrize( + "request_type", [datatransfer.ScheduleTransferRunsRequest, dict,] +) +def test_schedule_transfer_runs(request_type, transport: str = "grpc"): client = DataTransferServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2677,10 +2659,6 @@ def test_schedule_transfer_runs( assert isinstance(response, datatransfer.ScheduleTransferRunsResponse) -def test_schedule_transfer_runs_from_dict(): - test_schedule_transfer_runs(request_type=dict) - - def test_schedule_transfer_runs_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. @@ -2900,9 +2878,10 @@ async def test_schedule_transfer_runs_flattened_error_async(): ) -def test_start_manual_transfer_runs( - transport: str = "grpc", request_type=datatransfer.StartManualTransferRunsRequest -): +@pytest.mark.parametrize( + "request_type", [datatransfer.StartManualTransferRunsRequest, dict,] +) +def test_start_manual_transfer_runs(request_type, transport: str = "grpc"): client = DataTransferServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2928,10 +2907,6 @@ def test_start_manual_transfer_runs( assert isinstance(response, datatransfer.StartManualTransferRunsResponse) -def test_start_manual_transfer_runs_from_dict(): - test_start_manual_transfer_runs(request_type=dict) - - def test_start_manual_transfer_runs_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. @@ -3045,9 +3020,8 @@ async def test_start_manual_transfer_runs_field_headers_async(): assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] -def test_get_transfer_run( - transport: str = "grpc", request_type=datatransfer.GetTransferRunRequest -): +@pytest.mark.parametrize("request_type", [datatransfer.GetTransferRunRequest, dict,]) +def test_get_transfer_run(request_type, transport: str = "grpc"): client = DataTransferServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3085,10 +3059,6 @@ def test_get_transfer_run( assert response.notification_pubsub_topic == "notification_pubsub_topic_value" -def test_get_transfer_run_from_dict(): - test_get_transfer_run(request_type=dict) - - def test_get_transfer_run_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. @@ -3282,9 +3252,8 @@ async def test_get_transfer_run_flattened_error_async(): ) -def test_delete_transfer_run( - transport: str = "grpc", request_type=datatransfer.DeleteTransferRunRequest -): +@pytest.mark.parametrize("request_type", [datatransfer.DeleteTransferRunRequest, dict,]) +def test_delete_transfer_run(request_type, transport: str = "grpc"): client = DataTransferServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3310,10 +3279,6 @@ def test_delete_transfer_run( assert response is None -def test_delete_transfer_run_from_dict(): - test_delete_transfer_run(request_type=dict) - - def test_delete_transfer_run_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. @@ -3500,9 +3465,8 @@ async def test_delete_transfer_run_flattened_error_async(): ) -def test_list_transfer_runs( - transport: str = "grpc", request_type=datatransfer.ListTransferRunsRequest -): +@pytest.mark.parametrize("request_type", [datatransfer.ListTransferRunsRequest, dict,]) +def test_list_transfer_runs(request_type, transport: str = "grpc"): client = DataTransferServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3531,10 +3495,6 @@ def test_list_transfer_runs( assert response.next_page_token == "next_page_token_value" -def test_list_transfer_runs_from_dict(): - test_list_transfer_runs(request_type=dict) - - def test_list_transfer_runs_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. @@ -3730,8 +3690,10 @@ async def test_list_transfer_runs_flattened_error_async(): ) -def test_list_transfer_runs_pager(): - client = DataTransferServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_transfer_runs_pager(transport_name: str = "grpc"): + client = DataTransferServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3772,8 +3734,10 @@ def test_list_transfer_runs_pager(): assert all(isinstance(i, transfer.TransferRun) for i in results) -def test_list_transfer_runs_pages(): - client = DataTransferServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_transfer_runs_pages(transport_name: str = "grpc"): + client = DataTransferServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3888,9 +3852,8 @@ async def test_list_transfer_runs_async_pages(): assert page_.raw_page.next_page_token == token -def test_list_transfer_logs( - transport: str = "grpc", request_type=datatransfer.ListTransferLogsRequest -): +@pytest.mark.parametrize("request_type", [datatransfer.ListTransferLogsRequest, dict,]) +def test_list_transfer_logs(request_type, transport: str = "grpc"): client = DataTransferServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3919,10 +3882,6 @@ def test_list_transfer_logs( assert response.next_page_token == "next_page_token_value" -def test_list_transfer_logs_from_dict(): - test_list_transfer_logs(request_type=dict) - - def test_list_transfer_logs_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. @@ -4118,8 +4077,10 @@ async def test_list_transfer_logs_flattened_error_async(): ) -def test_list_transfer_logs_pager(): - client = DataTransferServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_transfer_logs_pager(transport_name: str = "grpc"): + client = DataTransferServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4163,8 +4124,10 @@ def test_list_transfer_logs_pager(): assert all(isinstance(i, transfer.TransferMessage) for i in results) -def test_list_transfer_logs_pages(): - client = DataTransferServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_transfer_logs_pages(transport_name: str = "grpc"): + client = DataTransferServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4288,9 +4251,8 @@ async def test_list_transfer_logs_async_pages(): assert page_.raw_page.next_page_token == token -def test_check_valid_creds( - transport: str = "grpc", request_type=datatransfer.CheckValidCredsRequest -): +@pytest.mark.parametrize("request_type", [datatransfer.CheckValidCredsRequest, dict,]) +def test_check_valid_creds(request_type, transport: str = "grpc"): client = DataTransferServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -4317,10 +4279,6 @@ def test_check_valid_creds( assert response.has_valid_creds is True -def test_check_valid_creds_from_dict(): - test_check_valid_creds(request_type=dict) - - def test_check_valid_creds_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. @@ -5089,7 +5047,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(