diff --git a/packages/google-area120-tables/google/area120/tables_v1alpha1/services/tables_service/transports/base.py b/packages/google-area120-tables/google/area120/tables_v1alpha1/services/tables_service/transports/base.py index 364133ebaa2b..db15e58d0fc5 100644 --- a/packages/google-area120-tables/google/area120/tables_v1alpha1/services/tables_service/transports/base.py +++ b/packages/google-area120-tables/google/area120/tables_v1alpha1/services/tables_service/transports/base.py @@ -107,7 +107,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-area120-tables/tests/unit/gapic/tables_v1alpha1/test_tables_service.py b/packages/google-area120-tables/tests/unit/gapic/tables_v1alpha1/test_tables_service.py index 6927a20818d0..99ac0fadf4a3 100644 --- a/packages/google-area120-tables/tests/unit/gapic/tables_v1alpha1/test_tables_service.py +++ b/packages/google-area120-tables/tests/unit/gapic/tables_v1alpha1/test_tables_service.py @@ -250,20 +250,20 @@ def test_tables_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, @@ -322,7 +322,7 @@ def test_tables_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 @@ -417,7 +417,7 @@ def test_tables_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, @@ -448,7 +448,7 @@ def test_tables_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", @@ -481,7 +481,8 @@ def test_tables_service_client_client_options_from_dict(): ) -def test_get_table(transport: str = "grpc", request_type=tables.GetTableRequest): +@pytest.mark.parametrize("request_type", [tables.GetTableRequest, dict,]) +def test_get_table(request_type, transport: str = "grpc"): client = TablesServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -509,10 +510,6 @@ def test_get_table(transport: str = "grpc", request_type=tables.GetTableRequest) assert response.display_name == "display_name_value" -def test_get_table_from_dict(): - test_get_table(request_type=dict) - - def test_get_table_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. @@ -685,7 +682,8 @@ async def test_get_table_flattened_error_async(): ) -def test_list_tables(transport: str = "grpc", request_type=tables.ListTablesRequest): +@pytest.mark.parametrize("request_type", [tables.ListTablesRequest, dict,]) +def test_list_tables(request_type, transport: str = "grpc"): client = TablesServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -712,10 +710,6 @@ def test_list_tables(transport: str = "grpc", request_type=tables.ListTablesRequ assert response.next_page_token == "next_page_token_value" -def test_list_tables_from_dict(): - test_list_tables(request_type=dict) - - def test_list_tables_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. @@ -766,8 +760,10 @@ async def test_list_tables_async_from_dict(): await test_list_tables_async(request_type=dict) -def test_list_tables_pager(): - client = TablesServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_tables_pager(transport_name: str = "grpc"): + client = TablesServiceClient( + 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_tables), "__call__") as call: @@ -793,8 +789,10 @@ def test_list_tables_pager(): assert all(isinstance(i, tables.Table) for i in results) -def test_list_tables_pages(): - client = TablesServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_tables_pages(transport_name: str = "grpc"): + client = TablesServiceClient( + 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_tables), "__call__") as call: @@ -869,9 +867,8 @@ async def test_list_tables_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_workspace( - transport: str = "grpc", request_type=tables.GetWorkspaceRequest -): +@pytest.mark.parametrize("request_type", [tables.GetWorkspaceRequest, dict,]) +def test_get_workspace(request_type, transport: str = "grpc"): client = TablesServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -899,10 +896,6 @@ def test_get_workspace( assert response.display_name == "display_name_value" -def test_get_workspace_from_dict(): - test_get_workspace(request_type=dict) - - def test_get_workspace_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. @@ -1075,9 +1068,8 @@ async def test_get_workspace_flattened_error_async(): ) -def test_list_workspaces( - transport: str = "grpc", request_type=tables.ListWorkspacesRequest -): +@pytest.mark.parametrize("request_type", [tables.ListWorkspacesRequest, dict,]) +def test_list_workspaces(request_type, transport: str = "grpc"): client = TablesServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1104,10 +1096,6 @@ def test_list_workspaces( assert response.next_page_token == "next_page_token_value" -def test_list_workspaces_from_dict(): - test_list_workspaces(request_type=dict) - - def test_list_workspaces_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. @@ -1158,8 +1146,10 @@ async def test_list_workspaces_async_from_dict(): await test_list_workspaces_async(request_type=dict) -def test_list_workspaces_pager(): - client = TablesServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_workspaces_pager(transport_name: str = "grpc"): + client = TablesServiceClient( + 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_workspaces), "__call__") as call: @@ -1193,8 +1183,10 @@ def test_list_workspaces_pager(): assert all(isinstance(i, tables.Workspace) for i in results) -def test_list_workspaces_pages(): - client = TablesServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_workspaces_pages(transport_name: str = "grpc"): + client = TablesServiceClient( + 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_workspaces), "__call__") as call: @@ -1293,7 +1285,8 @@ async def test_list_workspaces_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_row(transport: str = "grpc", request_type=tables.GetRowRequest): +@pytest.mark.parametrize("request_type", [tables.GetRowRequest, dict,]) +def test_get_row(request_type, transport: str = "grpc"): client = TablesServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1318,10 +1311,6 @@ def test_get_row(transport: str = "grpc", request_type=tables.GetRowRequest): assert response.name == "name_value" -def test_get_row_from_dict(): - test_get_row(request_type=dict) - - def test_get_row_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. @@ -1493,7 +1482,8 @@ async def test_get_row_flattened_error_async(): ) -def test_list_rows(transport: str = "grpc", request_type=tables.ListRowsRequest): +@pytest.mark.parametrize("request_type", [tables.ListRowsRequest, dict,]) +def test_list_rows(request_type, transport: str = "grpc"): client = TablesServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1520,10 +1510,6 @@ def test_list_rows(transport: str = "grpc", request_type=tables.ListRowsRequest) assert response.next_page_token == "next_page_token_value" -def test_list_rows_from_dict(): - test_list_rows(request_type=dict) - - def test_list_rows_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. @@ -1699,8 +1685,10 @@ async def test_list_rows_flattened_error_async(): ) -def test_list_rows_pager(): - client = TablesServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_rows_pager(transport_name: str = "grpc"): + client = TablesServiceClient( + 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_rows), "__call__") as call: @@ -1728,8 +1716,10 @@ def test_list_rows_pager(): assert all(isinstance(i, tables.Row) for i in results) -def test_list_rows_pages(): - client = TablesServiceClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_rows_pages(transport_name: str = "grpc"): + client = TablesServiceClient( + 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_rows), "__call__") as call: @@ -1801,7 +1791,8 @@ async def test_list_rows_async_pages(): assert page_.raw_page.next_page_token == token -def test_create_row(transport: str = "grpc", request_type=tables.CreateRowRequest): +@pytest.mark.parametrize("request_type", [tables.CreateRowRequest, dict,]) +def test_create_row(request_type, transport: str = "grpc"): client = TablesServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1826,10 +1817,6 @@ def test_create_row(transport: str = "grpc", request_type=tables.CreateRowReques assert response.name == "name_value" -def test_create_row_from_dict(): - test_create_row(request_type=dict) - - def test_create_row_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. @@ -2015,9 +2002,8 @@ async def test_create_row_flattened_error_async(): ) -def test_batch_create_rows( - transport: str = "grpc", request_type=tables.BatchCreateRowsRequest -): +@pytest.mark.parametrize("request_type", [tables.BatchCreateRowsRequest, dict,]) +def test_batch_create_rows(request_type, transport: str = "grpc"): client = TablesServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2043,10 +2029,6 @@ def test_batch_create_rows( assert isinstance(response, tables.BatchCreateRowsResponse) -def test_batch_create_rows_from_dict(): - test_batch_create_rows(request_type=dict) - - def test_batch_create_rows_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. @@ -2157,7 +2139,8 @@ async def test_batch_create_rows_field_headers_async(): assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] -def test_update_row(transport: str = "grpc", request_type=tables.UpdateRowRequest): +@pytest.mark.parametrize("request_type", [tables.UpdateRowRequest, dict,]) +def test_update_row(request_type, transport: str = "grpc"): client = TablesServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2182,10 +2165,6 @@ def test_update_row(transport: str = "grpc", request_type=tables.UpdateRowReques assert response.name == "name_value" -def test_update_row_from_dict(): - test_update_row(request_type=dict) - - def test_update_row_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. @@ -2373,9 +2352,8 @@ async def test_update_row_flattened_error_async(): ) -def test_batch_update_rows( - transport: str = "grpc", request_type=tables.BatchUpdateRowsRequest -): +@pytest.mark.parametrize("request_type", [tables.BatchUpdateRowsRequest, dict,]) +def test_batch_update_rows(request_type, transport: str = "grpc"): client = TablesServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2401,10 +2379,6 @@ def test_batch_update_rows( assert isinstance(response, tables.BatchUpdateRowsResponse) -def test_batch_update_rows_from_dict(): - test_batch_update_rows(request_type=dict) - - def test_batch_update_rows_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. @@ -2515,7 +2489,8 @@ async def test_batch_update_rows_field_headers_async(): assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] -def test_delete_row(transport: str = "grpc", request_type=tables.DeleteRowRequest): +@pytest.mark.parametrize("request_type", [tables.DeleteRowRequest, dict,]) +def test_delete_row(request_type, transport: str = "grpc"): client = TablesServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2539,10 +2514,6 @@ def test_delete_row(transport: str = "grpc", request_type=tables.DeleteRowReques assert response is None -def test_delete_row_from_dict(): - test_delete_row(request_type=dict) - - def test_delete_row_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. @@ -2711,9 +2682,8 @@ async def test_delete_row_flattened_error_async(): ) -def test_batch_delete_rows( - transport: str = "grpc", request_type=tables.BatchDeleteRowsRequest -): +@pytest.mark.parametrize("request_type", [tables.BatchDeleteRowsRequest, dict,]) +def test_batch_delete_rows(request_type, transport: str = "grpc"): client = TablesServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2739,10 +2709,6 @@ def test_batch_delete_rows( assert response is None -def test_batch_delete_rows_from_dict(): - test_batch_delete_rows(request_type=dict) - - def test_batch_delete_rows_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. @@ -3432,7 +3398,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(