From d81f15c1f56eb6c2736561e28cfdfd65d04dd6d8 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Sun, 9 Jan 2022 17:24:03 -0500 Subject: [PATCH] chore: use gapic-generator-python 0.58.4 (#27) 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 --- .../migration_service/transports/base.py | 1 - .../test_migration_service.py | 119 ++++++++---------- 2 files changed, 51 insertions(+), 69 deletions(-) diff --git a/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/migration_service/transports/base.py b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/migration_service/transports/base.py index 43410b4ff030..5b01d1bfc148 100644 --- a/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/migration_service/transports/base.py +++ b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/migration_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/packages/google-cloud-bigquery-migration/tests/unit/gapic/bigquery_migration_v2alpha/test_migration_service.py b/packages/google-cloud-bigquery-migration/tests/unit/gapic/bigquery_migration_v2alpha/test_migration_service.py index eb3103aabbb2..38c993b27d92 100644 --- a/packages/google-cloud-bigquery-migration/tests/unit/gapic/bigquery_migration_v2alpha/test_migration_service.py +++ b/packages/google-cloud-bigquery-migration/tests/unit/gapic/bigquery_migration_v2alpha/test_migration_service.py @@ -260,20 +260,20 @@ def test_migration_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, @@ -342,7 +342,7 @@ def test_migration_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 @@ -437,7 +437,7 @@ def test_migration_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, @@ -468,7 +468,7 @@ def test_migration_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", @@ -501,10 +501,10 @@ def test_migration_service_client_client_options_from_dict(): ) -def test_create_migration_workflow( - transport: str = "grpc", - request_type=migration_service.CreateMigrationWorkflowRequest, -): +@pytest.mark.parametrize( + "request_type", [migration_service.CreateMigrationWorkflowRequest, dict,] +) +def test_create_migration_workflow(request_type, transport: str = "grpc"): client = MigrationServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -537,10 +537,6 @@ def test_create_migration_workflow( assert response.state == migration_entities.MigrationWorkflow.State.DRAFT -def test_create_migration_workflow_from_dict(): - test_create_migration_workflow(request_type=dict) - - def test_create_migration_workflow_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. @@ -751,9 +747,10 @@ async def test_create_migration_workflow_flattened_error_async(): ) -def test_get_migration_workflow( - transport: str = "grpc", request_type=migration_service.GetMigrationWorkflowRequest -): +@pytest.mark.parametrize( + "request_type", [migration_service.GetMigrationWorkflowRequest, dict,] +) +def test_get_migration_workflow(request_type, transport: str = "grpc"): client = MigrationServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -786,10 +783,6 @@ def test_get_migration_workflow( assert response.state == migration_entities.MigrationWorkflow.State.DRAFT -def test_get_migration_workflow_from_dict(): - test_get_migration_workflow(request_type=dict) - - def test_get_migration_workflow_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. @@ -984,10 +977,10 @@ async def test_get_migration_workflow_flattened_error_async(): ) -def test_list_migration_workflows( - transport: str = "grpc", - request_type=migration_service.ListMigrationWorkflowsRequest, -): +@pytest.mark.parametrize( + "request_type", [migration_service.ListMigrationWorkflowsRequest, dict,] +) +def test_list_migration_workflows(request_type, transport: str = "grpc"): client = MigrationServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1016,10 +1009,6 @@ def test_list_migration_workflows( assert response.next_page_token == "next_page_token_value" -def test_list_migration_workflows_from_dict(): - test_list_migration_workflows(request_type=dict) - - def test_list_migration_workflows_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. @@ -1210,8 +1199,10 @@ async def test_list_migration_workflows_flattened_error_async(): ) -def test_list_migration_workflows_pager(): - client = MigrationServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_migration_workflows_pager(transport_name: str = "grpc"): + client = MigrationServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1256,8 +1247,10 @@ def test_list_migration_workflows_pager(): assert all(isinstance(i, migration_entities.MigrationWorkflow) for i in results) -def test_list_migration_workflows_pages(): - client = MigrationServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_migration_workflows_pages(transport_name: str = "grpc"): + client = MigrationServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1386,10 +1379,10 @@ async def test_list_migration_workflows_async_pages(): assert page_.raw_page.next_page_token == token -def test_delete_migration_workflow( - transport: str = "grpc", - request_type=migration_service.DeleteMigrationWorkflowRequest, -): +@pytest.mark.parametrize( + "request_type", [migration_service.DeleteMigrationWorkflowRequest, dict,] +) +def test_delete_migration_workflow(request_type, transport: str = "grpc"): client = MigrationServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1415,10 +1408,6 @@ def test_delete_migration_workflow( assert response is None -def test_delete_migration_workflow_from_dict(): - test_delete_migration_workflow(request_type=dict) - - def test_delete_migration_workflow_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. @@ -1600,10 +1589,10 @@ async def test_delete_migration_workflow_flattened_error_async(): ) -def test_start_migration_workflow( - transport: str = "grpc", - request_type=migration_service.StartMigrationWorkflowRequest, -): +@pytest.mark.parametrize( + "request_type", [migration_service.StartMigrationWorkflowRequest, dict,] +) +def test_start_migration_workflow(request_type, transport: str = "grpc"): client = MigrationServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1629,10 +1618,6 @@ def test_start_migration_workflow( assert response is None -def test_start_migration_workflow_from_dict(): - test_start_migration_workflow(request_type=dict) - - def test_start_migration_workflow_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. @@ -1814,9 +1799,10 @@ async def test_start_migration_workflow_flattened_error_async(): ) -def test_get_migration_subtask( - transport: str = "grpc", request_type=migration_service.GetMigrationSubtaskRequest -): +@pytest.mark.parametrize( + "request_type", [migration_service.GetMigrationSubtaskRequest, dict,] +) +def test_get_migration_subtask(request_type, transport: str = "grpc"): client = MigrationServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1853,10 +1839,6 @@ def test_get_migration_subtask( assert response.resource_error_count == 2169 -def test_get_migration_subtask_from_dict(): - test_get_migration_subtask(request_type=dict) - - def test_get_migration_subtask_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. @@ -2055,9 +2037,10 @@ async def test_get_migration_subtask_flattened_error_async(): ) -def test_list_migration_subtasks( - transport: str = "grpc", request_type=migration_service.ListMigrationSubtasksRequest -): +@pytest.mark.parametrize( + "request_type", [migration_service.ListMigrationSubtasksRequest, dict,] +) +def test_list_migration_subtasks(request_type, transport: str = "grpc"): client = MigrationServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2086,10 +2069,6 @@ def test_list_migration_subtasks( assert response.next_page_token == "next_page_token_value" -def test_list_migration_subtasks_from_dict(): - test_list_migration_subtasks(request_type=dict) - - def test_list_migration_subtasks_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. @@ -2280,8 +2259,10 @@ async def test_list_migration_subtasks_flattened_error_async(): ) -def test_list_migration_subtasks_pager(): - client = MigrationServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_migration_subtasks_pager(transport_name: str = "grpc"): + client = MigrationServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2326,8 +2307,10 @@ def test_list_migration_subtasks_pager(): assert all(isinstance(i, migration_entities.MigrationSubtask) for i in results) -def test_list_migration_subtasks_pages(): - client = MigrationServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_migration_subtasks_pages(transport_name: str = "grpc"): + client = MigrationServiceClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3004,7 +2987,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(