diff --git a/google/cloud/spanner_admin_database_v1/services/database_admin/transports/base.py b/google/cloud/spanner_admin_database_v1/services/database_admin/transports/base.py index 48518dceb4..4869fd03d5 100644 --- a/google/cloud/spanner_admin_database_v1/services/database_admin/transports/base.py +++ b/google/cloud/spanner_admin_database_v1/services/database_admin/transports/base.py @@ -111,7 +111,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/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/base.py b/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/base.py index ff780ccaae..f059f8eb67 100644 --- a/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/base.py +++ b/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/base.py @@ -109,7 +109,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/google/cloud/spanner_v1/services/spanner/transports/base.py b/google/cloud/spanner_v1/services/spanner/transports/base.py index cfbc526a38..f3d946b51d 100644 --- a/google/cloud/spanner_v1/services/spanner/transports/base.py +++ b/google/cloud/spanner_v1/services/spanner/transports/base.py @@ -106,7 +106,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/spanner_admin_database_v1/test_database_admin.py b/tests/unit/gapic/spanner_admin_database_v1/test_database_admin.py index 4af539dd4e..53f91de384 100644 --- a/tests/unit/gapic/spanner_admin_database_v1/test_database_admin.py +++ b/tests/unit/gapic/spanner_admin_database_v1/test_database_admin.py @@ -266,20 +266,20 @@ def test_database_admin_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, @@ -338,7 +338,7 @@ def test_database_admin_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 @@ -433,7 +433,7 @@ def test_database_admin_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, @@ -464,7 +464,7 @@ def test_database_admin_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", @@ -497,9 +497,10 @@ def test_database_admin_client_client_options_from_dict(): ) -def test_list_databases( - transport: str = "grpc", request_type=spanner_database_admin.ListDatabasesRequest -): +@pytest.mark.parametrize( + "request_type", [spanner_database_admin.ListDatabasesRequest, dict,] +) +def test_list_databases(request_type, transport: str = "grpc"): client = DatabaseAdminClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -526,10 +527,6 @@ def test_list_databases( assert response.next_page_token == "next_page_token_value" -def test_list_databases_from_dict(): - test_list_databases(request_type=dict) - - def test_list_databases_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. @@ -708,8 +705,10 @@ async def test_list_databases_flattened_error_async(): ) -def test_list_databases_pager(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_databases_pager(transport_name: str = "grpc"): + client = DatabaseAdminClient( + 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_databases), "__call__") as call: @@ -751,8 +750,10 @@ def test_list_databases_pager(): assert all(isinstance(i, spanner_database_admin.Database) for i in results) -def test_list_databases_pages(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_databases_pages(transport_name: str = "grpc"): + client = DatabaseAdminClient( + 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_databases), "__call__") as call: @@ -866,9 +867,10 @@ async def test_list_databases_async_pages(): assert page_.raw_page.next_page_token == token -def test_create_database( - transport: str = "grpc", request_type=spanner_database_admin.CreateDatabaseRequest -): +@pytest.mark.parametrize( + "request_type", [spanner_database_admin.CreateDatabaseRequest, dict,] +) +def test_create_database(request_type, transport: str = "grpc"): client = DatabaseAdminClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -892,10 +894,6 @@ def test_create_database( assert isinstance(response, future.Future) -def test_create_database_from_dict(): - test_create_database(request_type=dict) - - def test_create_database_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. @@ -1085,9 +1083,10 @@ async def test_create_database_flattened_error_async(): ) -def test_get_database( - transport: str = "grpc", request_type=spanner_database_admin.GetDatabaseRequest -): +@pytest.mark.parametrize( + "request_type", [spanner_database_admin.GetDatabaseRequest, dict,] +) +def test_get_database(request_type, transport: str = "grpc"): client = DatabaseAdminClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1120,10 +1119,6 @@ def test_get_database( assert response.default_leader == "default_leader_value" -def test_get_database_from_dict(): - test_get_database(request_type=dict) - - def test_get_database_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. @@ -1308,10 +1303,10 @@ async def test_get_database_flattened_error_async(): ) -def test_update_database_ddl( - transport: str = "grpc", - request_type=spanner_database_admin.UpdateDatabaseDdlRequest, -): +@pytest.mark.parametrize( + "request_type", [spanner_database_admin.UpdateDatabaseDdlRequest, dict,] +) +def test_update_database_ddl(request_type, transport: str = "grpc"): client = DatabaseAdminClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1337,10 +1332,6 @@ def test_update_database_ddl( assert isinstance(response, future.Future) -def test_update_database_ddl_from_dict(): - test_update_database_ddl(request_type=dict) - - def test_update_database_ddl_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. @@ -1542,9 +1533,10 @@ async def test_update_database_ddl_flattened_error_async(): ) -def test_drop_database( - transport: str = "grpc", request_type=spanner_database_admin.DropDatabaseRequest -): +@pytest.mark.parametrize( + "request_type", [spanner_database_admin.DropDatabaseRequest, dict,] +) +def test_drop_database(request_type, transport: str = "grpc"): client = DatabaseAdminClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1568,10 +1560,6 @@ def test_drop_database( assert response is None -def test_drop_database_from_dict(): - test_drop_database(request_type=dict) - - def test_drop_database_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. @@ -1741,9 +1729,10 @@ async def test_drop_database_flattened_error_async(): ) -def test_get_database_ddl( - transport: str = "grpc", request_type=spanner_database_admin.GetDatabaseDdlRequest -): +@pytest.mark.parametrize( + "request_type", [spanner_database_admin.GetDatabaseDdlRequest, dict,] +) +def test_get_database_ddl(request_type, transport: str = "grpc"): client = DatabaseAdminClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1770,10 +1759,6 @@ def test_get_database_ddl( assert response.statements == ["statements_value"] -def test_get_database_ddl_from_dict(): - test_get_database_ddl(request_type=dict) - - def test_get_database_ddl_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. @@ -1952,9 +1937,8 @@ async def test_get_database_ddl_flattened_error_async(): ) -def test_set_iam_policy( - transport: str = "grpc", request_type=iam_policy_pb2.SetIamPolicyRequest -): +@pytest.mark.parametrize("request_type", [iam_policy_pb2.SetIamPolicyRequest, dict,]) +def test_set_iam_policy(request_type, transport: str = "grpc"): client = DatabaseAdminClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1980,10 +1964,6 @@ def test_set_iam_policy( assert response.etag == b"etag_blob" -def test_set_iam_policy_from_dict(): - test_set_iam_policy(request_type=dict) - - def test_set_iam_policy_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. @@ -2171,9 +2151,8 @@ async def test_set_iam_policy_flattened_error_async(): ) -def test_get_iam_policy( - transport: str = "grpc", request_type=iam_policy_pb2.GetIamPolicyRequest -): +@pytest.mark.parametrize("request_type", [iam_policy_pb2.GetIamPolicyRequest, dict,]) +def test_get_iam_policy(request_type, transport: str = "grpc"): client = DatabaseAdminClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2199,10 +2178,6 @@ def test_get_iam_policy( assert response.etag == b"etag_blob" -def test_get_iam_policy_from_dict(): - test_get_iam_policy(request_type=dict) - - def test_get_iam_policy_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. @@ -2390,9 +2365,10 @@ async def test_get_iam_policy_flattened_error_async(): ) -def test_test_iam_permissions( - transport: str = "grpc", request_type=iam_policy_pb2.TestIamPermissionsRequest -): +@pytest.mark.parametrize( + "request_type", [iam_policy_pb2.TestIamPermissionsRequest, dict,] +) +def test_test_iam_permissions(request_type, transport: str = "grpc"): client = DatabaseAdminClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2421,10 +2397,6 @@ def test_test_iam_permissions( assert response.permissions == ["permissions_value"] -def test_test_iam_permissions_from_dict(): - test_test_iam_permissions(request_type=dict) - - def test_test_iam_permissions_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. @@ -2646,9 +2618,8 @@ async def test_test_iam_permissions_flattened_error_async(): ) -def test_create_backup( - transport: str = "grpc", request_type=gsad_backup.CreateBackupRequest -): +@pytest.mark.parametrize("request_type", [gsad_backup.CreateBackupRequest, dict,]) +def test_create_backup(request_type, transport: str = "grpc"): client = DatabaseAdminClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2672,10 +2643,6 @@ def test_create_backup( assert isinstance(response, future.Future) -def test_create_backup_from_dict(): - test_create_backup(request_type=dict) - - def test_create_backup_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. @@ -2876,7 +2843,8 @@ async def test_create_backup_flattened_error_async(): ) -def test_get_backup(transport: str = "grpc", request_type=backup.GetBackupRequest): +@pytest.mark.parametrize("request_type", [backup.GetBackupRequest, dict,]) +def test_get_backup(request_type, transport: str = "grpc"): client = DatabaseAdminClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2911,10 +2879,6 @@ def test_get_backup(transport: str = "grpc", request_type=backup.GetBackupReques assert response.referencing_databases == ["referencing_databases_value"] -def test_get_backup_from_dict(): - test_get_backup(request_type=dict) - - def test_get_backup_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. @@ -3096,9 +3060,8 @@ async def test_get_backup_flattened_error_async(): ) -def test_update_backup( - transport: str = "grpc", request_type=gsad_backup.UpdateBackupRequest -): +@pytest.mark.parametrize("request_type", [gsad_backup.UpdateBackupRequest, dict,]) +def test_update_backup(request_type, transport: str = "grpc"): client = DatabaseAdminClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3133,10 +3096,6 @@ def test_update_backup( assert response.referencing_databases == ["referencing_databases_value"] -def test_update_backup_from_dict(): - test_update_backup(request_type=dict) - - def test_update_backup_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. @@ -3334,9 +3293,8 @@ async def test_update_backup_flattened_error_async(): ) -def test_delete_backup( - transport: str = "grpc", request_type=backup.DeleteBackupRequest -): +@pytest.mark.parametrize("request_type", [backup.DeleteBackupRequest, dict,]) +def test_delete_backup(request_type, transport: str = "grpc"): client = DatabaseAdminClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3360,10 +3318,6 @@ def test_delete_backup( assert response is None -def test_delete_backup_from_dict(): - test_delete_backup(request_type=dict) - - def test_delete_backup_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. @@ -3532,7 +3486,8 @@ async def test_delete_backup_flattened_error_async(): ) -def test_list_backups(transport: str = "grpc", request_type=backup.ListBackupsRequest): +@pytest.mark.parametrize("request_type", [backup.ListBackupsRequest, dict,]) +def test_list_backups(request_type, transport: str = "grpc"): client = DatabaseAdminClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3559,10 +3514,6 @@ def test_list_backups(transport: str = "grpc", request_type=backup.ListBackupsRe assert response.next_page_token == "next_page_token_value" -def test_list_backups_from_dict(): - test_list_backups(request_type=dict) - - def test_list_backups_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. @@ -3738,8 +3689,10 @@ async def test_list_backups_flattened_error_async(): ) -def test_list_backups_pager(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_backups_pager(transport_name: str = "grpc"): + client = DatabaseAdminClient( + 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_backups), "__call__") as call: @@ -3770,8 +3723,10 @@ def test_list_backups_pager(): assert all(isinstance(i, backup.Backup) for i in results) -def test_list_backups_pages(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_backups_pages(transport_name: str = "grpc"): + client = DatabaseAdminClient( + 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_backups), "__call__") as call: @@ -3852,9 +3807,10 @@ async def test_list_backups_async_pages(): assert page_.raw_page.next_page_token == token -def test_restore_database( - transport: str = "grpc", request_type=spanner_database_admin.RestoreDatabaseRequest -): +@pytest.mark.parametrize( + "request_type", [spanner_database_admin.RestoreDatabaseRequest, dict,] +) +def test_restore_database(request_type, transport: str = "grpc"): client = DatabaseAdminClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3878,10 +3834,6 @@ def test_restore_database( assert isinstance(response, future.Future) -def test_restore_database_from_dict(): - test_restore_database(request_type=dict) - - def test_restore_database_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. @@ -4079,10 +4031,10 @@ async def test_restore_database_flattened_error_async(): ) -def test_list_database_operations( - transport: str = "grpc", - request_type=spanner_database_admin.ListDatabaseOperationsRequest, -): +@pytest.mark.parametrize( + "request_type", [spanner_database_admin.ListDatabaseOperationsRequest, dict,] +) +def test_list_database_operations(request_type, transport: str = "grpc"): client = DatabaseAdminClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -4111,10 +4063,6 @@ def test_list_database_operations( assert response.next_page_token == "next_page_token_value" -def test_list_database_operations_from_dict(): - test_list_database_operations(request_type=dict) - - def test_list_database_operations_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. @@ -4307,8 +4255,10 @@ async def test_list_database_operations_flattened_error_async(): ) -def test_list_database_operations_pager(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_database_operations_pager(transport_name: str = "grpc"): + client = DatabaseAdminClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4349,8 +4299,10 @@ def test_list_database_operations_pager(): assert all(isinstance(i, operations_pb2.Operation) for i in results) -def test_list_database_operations_pages(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_database_operations_pages(transport_name: str = "grpc"): + client = DatabaseAdminClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4461,9 +4413,8 @@ async def test_list_database_operations_async_pages(): assert page_.raw_page.next_page_token == token -def test_list_backup_operations( - transport: str = "grpc", request_type=backup.ListBackupOperationsRequest -): +@pytest.mark.parametrize("request_type", [backup.ListBackupOperationsRequest, dict,]) +def test_list_backup_operations(request_type, transport: str = "grpc"): client = DatabaseAdminClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -4492,10 +4443,6 @@ def test_list_backup_operations( assert response.next_page_token == "next_page_token_value" -def test_list_backup_operations_from_dict(): - test_list_backup_operations(request_type=dict) - - def test_list_backup_operations_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. @@ -4685,8 +4632,10 @@ async def test_list_backup_operations_flattened_error_async(): ) -def test_list_backup_operations_pager(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_backup_operations_pager(transport_name: str = "grpc"): + client = DatabaseAdminClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4725,8 +4674,10 @@ def test_list_backup_operations_pager(): assert all(isinstance(i, operations_pb2.Operation) for i in results) -def test_list_backup_operations_pages(): - client = DatabaseAdminClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_backup_operations_pages(transport_name: str = "grpc"): + client = DatabaseAdminClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -5510,7 +5461,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( diff --git a/tests/unit/gapic/spanner_admin_instance_v1/test_instance_admin.py b/tests/unit/gapic/spanner_admin_instance_v1/test_instance_admin.py index 247619dc82..e6835d7a3b 100644 --- a/tests/unit/gapic/spanner_admin_instance_v1/test_instance_admin.py +++ b/tests/unit/gapic/spanner_admin_instance_v1/test_instance_admin.py @@ -259,20 +259,20 @@ def test_instance_admin_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, @@ -331,7 +331,7 @@ def test_instance_admin_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 @@ -426,7 +426,7 @@ def test_instance_admin_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, @@ -457,7 +457,7 @@ def test_instance_admin_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", @@ -490,10 +490,10 @@ def test_instance_admin_client_client_options_from_dict(): ) -def test_list_instance_configs( - transport: str = "grpc", - request_type=spanner_instance_admin.ListInstanceConfigsRequest, -): +@pytest.mark.parametrize( + "request_type", [spanner_instance_admin.ListInstanceConfigsRequest, dict,] +) +def test_list_instance_configs(request_type, transport: str = "grpc"): client = InstanceAdminClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -522,10 +522,6 @@ def test_list_instance_configs( assert response.next_page_token == "next_page_token_value" -def test_list_instance_configs_from_dict(): - test_list_instance_configs(request_type=dict) - - def test_list_instance_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. @@ -716,8 +712,10 @@ async def test_list_instance_configs_flattened_error_async(): ) -def test_list_instance_configs_pager(): - client = InstanceAdminClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_instance_configs_pager(transport_name: str = "grpc"): + client = InstanceAdminClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -764,8 +762,10 @@ def test_list_instance_configs_pager(): ) -def test_list_instance_configs_pages(): - client = InstanceAdminClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_instance_configs_pages(transport_name: str = "grpc"): + client = InstanceAdminClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -890,10 +890,10 @@ async def test_list_instance_configs_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_instance_config( - transport: str = "grpc", - request_type=spanner_instance_admin.GetInstanceConfigRequest, -): +@pytest.mark.parametrize( + "request_type", [spanner_instance_admin.GetInstanceConfigRequest, dict,] +) +def test_get_instance_config(request_type, transport: str = "grpc"): client = InstanceAdminClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -926,10 +926,6 @@ def test_get_instance_config( assert response.leader_options == ["leader_options_value"] -def test_get_instance_config_from_dict(): - test_get_instance_config(request_type=dict) - - def test_get_instance_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. @@ -1124,9 +1120,10 @@ async def test_get_instance_config_flattened_error_async(): ) -def test_list_instances( - transport: str = "grpc", request_type=spanner_instance_admin.ListInstancesRequest -): +@pytest.mark.parametrize( + "request_type", [spanner_instance_admin.ListInstancesRequest, dict,] +) +def test_list_instances(request_type, transport: str = "grpc"): client = InstanceAdminClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1153,10 +1150,6 @@ def test_list_instances( assert response.next_page_token == "next_page_token_value" -def test_list_instances_from_dict(): - test_list_instances(request_type=dict) - - def test_list_instances_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. @@ -1335,8 +1328,10 @@ async def test_list_instances_flattened_error_async(): ) -def test_list_instances_pager(): - client = InstanceAdminClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_instances_pager(transport_name: str = "grpc"): + client = InstanceAdminClient( + 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_instances), "__call__") as call: @@ -1378,8 +1373,10 @@ def test_list_instances_pager(): assert all(isinstance(i, spanner_instance_admin.Instance) for i in results) -def test_list_instances_pages(): - client = InstanceAdminClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_instances_pages(transport_name: str = "grpc"): + client = InstanceAdminClient( + 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_instances), "__call__") as call: @@ -1493,9 +1490,10 @@ async def test_list_instances_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_instance( - transport: str = "grpc", request_type=spanner_instance_admin.GetInstanceRequest -): +@pytest.mark.parametrize( + "request_type", [spanner_instance_admin.GetInstanceRequest, dict,] +) +def test_get_instance(request_type, transport: str = "grpc"): client = InstanceAdminClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1534,10 +1532,6 @@ def test_get_instance( assert response.endpoint_uris == ["endpoint_uris_value"] -def test_get_instance_from_dict(): - test_get_instance(request_type=dict) - - def test_get_instance_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. @@ -1728,9 +1722,10 @@ async def test_get_instance_flattened_error_async(): ) -def test_create_instance( - transport: str = "grpc", request_type=spanner_instance_admin.CreateInstanceRequest -): +@pytest.mark.parametrize( + "request_type", [spanner_instance_admin.CreateInstanceRequest, dict,] +) +def test_create_instance(request_type, transport: str = "grpc"): client = InstanceAdminClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1754,10 +1749,6 @@ def test_create_instance( assert isinstance(response, future.Future) -def test_create_instance_from_dict(): - test_create_instance(request_type=dict) - - def test_create_instance_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. @@ -1959,9 +1950,10 @@ async def test_create_instance_flattened_error_async(): ) -def test_update_instance( - transport: str = "grpc", request_type=spanner_instance_admin.UpdateInstanceRequest -): +@pytest.mark.parametrize( + "request_type", [spanner_instance_admin.UpdateInstanceRequest, dict,] +) +def test_update_instance(request_type, transport: str = "grpc"): client = InstanceAdminClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1985,10 +1977,6 @@ def test_update_instance( assert isinstance(response, future.Future) -def test_update_instance_from_dict(): - test_update_instance(request_type=dict) - - def test_update_instance_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. @@ -2184,9 +2172,10 @@ async def test_update_instance_flattened_error_async(): ) -def test_delete_instance( - transport: str = "grpc", request_type=spanner_instance_admin.DeleteInstanceRequest -): +@pytest.mark.parametrize( + "request_type", [spanner_instance_admin.DeleteInstanceRequest, dict,] +) +def test_delete_instance(request_type, transport: str = "grpc"): client = InstanceAdminClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2210,10 +2199,6 @@ def test_delete_instance( assert response is None -def test_delete_instance_from_dict(): - test_delete_instance(request_type=dict) - - def test_delete_instance_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. @@ -2383,9 +2368,8 @@ async def test_delete_instance_flattened_error_async(): ) -def test_set_iam_policy( - transport: str = "grpc", request_type=iam_policy_pb2.SetIamPolicyRequest -): +@pytest.mark.parametrize("request_type", [iam_policy_pb2.SetIamPolicyRequest, dict,]) +def test_set_iam_policy(request_type, transport: str = "grpc"): client = InstanceAdminClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2411,10 +2395,6 @@ def test_set_iam_policy( assert response.etag == b"etag_blob" -def test_set_iam_policy_from_dict(): - test_set_iam_policy(request_type=dict) - - def test_set_iam_policy_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. @@ -2602,9 +2582,8 @@ async def test_set_iam_policy_flattened_error_async(): ) -def test_get_iam_policy( - transport: str = "grpc", request_type=iam_policy_pb2.GetIamPolicyRequest -): +@pytest.mark.parametrize("request_type", [iam_policy_pb2.GetIamPolicyRequest, dict,]) +def test_get_iam_policy(request_type, transport: str = "grpc"): client = InstanceAdminClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2630,10 +2609,6 @@ def test_get_iam_policy( assert response.etag == b"etag_blob" -def test_get_iam_policy_from_dict(): - test_get_iam_policy(request_type=dict) - - def test_get_iam_policy_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. @@ -2821,9 +2796,10 @@ async def test_get_iam_policy_flattened_error_async(): ) -def test_test_iam_permissions( - transport: str = "grpc", request_type=iam_policy_pb2.TestIamPermissionsRequest -): +@pytest.mark.parametrize( + "request_type", [iam_policy_pb2.TestIamPermissionsRequest, dict,] +) +def test_test_iam_permissions(request_type, transport: str = "grpc"): client = InstanceAdminClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2852,10 +2828,6 @@ def test_test_iam_permissions( assert response.permissions == ["permissions_value"] -def test_test_iam_permissions_from_dict(): - test_test_iam_permissions(request_type=dict) - - def test_test_iam_permissions_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. @@ -3661,7 +3633,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( diff --git a/tests/unit/gapic/spanner_v1/test_spanner.py b/tests/unit/gapic/spanner_v1/test_spanner.py index 3678053f44..401b56d752 100644 --- a/tests/unit/gapic/spanner_v1/test_spanner.py +++ b/tests/unit/gapic/spanner_v1/test_spanner.py @@ -234,20 +234,20 @@ def test_spanner_client_client_options(client_class, transport_class, transport_ # 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, @@ -302,7 +302,7 @@ def test_spanner_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 @@ -393,7 +393,7 @@ def test_spanner_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, @@ -420,7 +420,7 @@ def test_spanner_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", @@ -451,9 +451,8 @@ def test_spanner_client_client_options_from_dict(): ) -def test_create_session( - transport: str = "grpc", request_type=spanner.CreateSessionRequest -): +@pytest.mark.parametrize("request_type", [spanner.CreateSessionRequest, dict,]) +def test_create_session(request_type, transport: str = "grpc"): client = SpannerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -478,10 +477,6 @@ def test_create_session( assert response.name == "name_value" -def test_create_session_from_dict(): - test_create_session(request_type=dict) - - def test_create_session_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. @@ -647,9 +642,8 @@ async def test_create_session_flattened_error_async(): ) -def test_batch_create_sessions( - transport: str = "grpc", request_type=spanner.BatchCreateSessionsRequest -): +@pytest.mark.parametrize("request_type", [spanner.BatchCreateSessionsRequest, dict,]) +def test_batch_create_sessions(request_type, transport: str = "grpc"): client = SpannerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -675,10 +669,6 @@ def test_batch_create_sessions( assert isinstance(response, spanner.BatchCreateSessionsResponse) -def test_batch_create_sessions_from_dict(): - test_batch_create_sessions(request_type=dict) - - def test_batch_create_sessions_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. @@ -873,7 +863,8 @@ async def test_batch_create_sessions_flattened_error_async(): ) -def test_get_session(transport: str = "grpc", request_type=spanner.GetSessionRequest): +@pytest.mark.parametrize("request_type", [spanner.GetSessionRequest, dict,]) +def test_get_session(request_type, transport: str = "grpc"): client = SpannerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -898,10 +889,6 @@ def test_get_session(transport: str = "grpc", request_type=spanner.GetSessionReq assert response.name == "name_value" -def test_get_session_from_dict(): - test_get_session(request_type=dict) - - def test_get_session_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. @@ -1067,9 +1054,8 @@ async def test_get_session_flattened_error_async(): ) -def test_list_sessions( - transport: str = "grpc", request_type=spanner.ListSessionsRequest -): +@pytest.mark.parametrize("request_type", [spanner.ListSessionsRequest, dict,]) +def test_list_sessions(request_type, transport: str = "grpc"): client = SpannerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1096,10 +1082,6 @@ def test_list_sessions( assert response.next_page_token == "next_page_token_value" -def test_list_sessions_from_dict(): - test_list_sessions(request_type=dict) - - def test_list_sessions_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. @@ -1269,8 +1251,10 @@ async def test_list_sessions_flattened_error_async(): ) -def test_list_sessions_pager(): - client = SpannerClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_sessions_pager(transport_name: str = "grpc"): + client = SpannerClient( + 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_sessions), "__call__") as call: @@ -1303,8 +1287,10 @@ def test_list_sessions_pager(): assert all(isinstance(i, spanner.Session) for i in results) -def test_list_sessions_pages(): - client = SpannerClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_sessions_pages(transport_name: str = "grpc"): + client = SpannerClient( + 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_sessions), "__call__") as call: @@ -1391,9 +1377,8 @@ async def test_list_sessions_async_pages(): assert page_.raw_page.next_page_token == token -def test_delete_session( - transport: str = "grpc", request_type=spanner.DeleteSessionRequest -): +@pytest.mark.parametrize("request_type", [spanner.DeleteSessionRequest, dict,]) +def test_delete_session(request_type, transport: str = "grpc"): client = SpannerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1417,10 +1402,6 @@ def test_delete_session( assert response is None -def test_delete_session_from_dict(): - test_delete_session(request_type=dict) - - def test_delete_session_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. @@ -1583,7 +1564,8 @@ async def test_delete_session_flattened_error_async(): ) -def test_execute_sql(transport: str = "grpc", request_type=spanner.ExecuteSqlRequest): +@pytest.mark.parametrize("request_type", [spanner.ExecuteSqlRequest, dict,]) +def test_execute_sql(request_type, transport: str = "grpc"): client = SpannerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1607,10 +1589,6 @@ def test_execute_sql(transport: str = "grpc", request_type=spanner.ExecuteSqlReq assert isinstance(response, result_set.ResultSet) -def test_execute_sql_from_dict(): - test_execute_sql(request_type=dict) - - def test_execute_sql_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. @@ -1711,9 +1689,8 @@ async def test_execute_sql_field_headers_async(): assert ("x-goog-request-params", "session=session/value",) in kw["metadata"] -def test_execute_streaming_sql( - transport: str = "grpc", request_type=spanner.ExecuteSqlRequest -): +@pytest.mark.parametrize("request_type", [spanner.ExecuteSqlRequest, dict,]) +def test_execute_streaming_sql(request_type, transport: str = "grpc"): client = SpannerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1740,10 +1717,6 @@ def test_execute_streaming_sql( assert isinstance(message, result_set.PartialResultSet) -def test_execute_streaming_sql_from_dict(): - test_execute_streaming_sql(request_type=dict) - - def test_execute_streaming_sql_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. @@ -1855,9 +1828,8 @@ async def test_execute_streaming_sql_field_headers_async(): assert ("x-goog-request-params", "session=session/value",) in kw["metadata"] -def test_execute_batch_dml( - transport: str = "grpc", request_type=spanner.ExecuteBatchDmlRequest -): +@pytest.mark.parametrize("request_type", [spanner.ExecuteBatchDmlRequest, dict,]) +def test_execute_batch_dml(request_type, transport: str = "grpc"): client = SpannerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1883,10 +1855,6 @@ def test_execute_batch_dml( assert isinstance(response, spanner.ExecuteBatchDmlResponse) -def test_execute_batch_dml_from_dict(): - test_execute_batch_dml(request_type=dict) - - def test_execute_batch_dml_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. @@ -1995,7 +1963,8 @@ async def test_execute_batch_dml_field_headers_async(): assert ("x-goog-request-params", "session=session/value",) in kw["metadata"] -def test_read(transport: str = "grpc", request_type=spanner.ReadRequest): +@pytest.mark.parametrize("request_type", [spanner.ReadRequest, dict,]) +def test_read(request_type, transport: str = "grpc"): client = SpannerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2019,10 +1988,6 @@ def test_read(transport: str = "grpc", request_type=spanner.ReadRequest): assert isinstance(response, result_set.ResultSet) -def test_read_from_dict(): - test_read(request_type=dict) - - def test_read_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. @@ -2123,7 +2088,8 @@ async def test_read_field_headers_async(): assert ("x-goog-request-params", "session=session/value",) in kw["metadata"] -def test_streaming_read(transport: str = "grpc", request_type=spanner.ReadRequest): +@pytest.mark.parametrize("request_type", [spanner.ReadRequest, dict,]) +def test_streaming_read(request_type, transport: str = "grpc"): client = SpannerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2148,10 +2114,6 @@ def test_streaming_read(transport: str = "grpc", request_type=spanner.ReadReques assert isinstance(message, result_set.PartialResultSet) -def test_streaming_read_from_dict(): - test_streaming_read(request_type=dict) - - def test_streaming_read_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. @@ -2255,9 +2217,8 @@ async def test_streaming_read_field_headers_async(): assert ("x-goog-request-params", "session=session/value",) in kw["metadata"] -def test_begin_transaction( - transport: str = "grpc", request_type=spanner.BeginTransactionRequest -): +@pytest.mark.parametrize("request_type", [spanner.BeginTransactionRequest, dict,]) +def test_begin_transaction(request_type, transport: str = "grpc"): client = SpannerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2284,10 +2245,6 @@ def test_begin_transaction( assert response.id == b"id_blob" -def test_begin_transaction_from_dict(): - test_begin_transaction(request_type=dict) - - def test_begin_transaction_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. @@ -2485,7 +2442,8 @@ async def test_begin_transaction_flattened_error_async(): ) -def test_commit(transport: str = "grpc", request_type=spanner.CommitRequest): +@pytest.mark.parametrize("request_type", [spanner.CommitRequest, dict,]) +def test_commit(request_type, transport: str = "grpc"): client = SpannerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2509,10 +2467,6 @@ def test_commit(transport: str = "grpc", request_type=spanner.CommitRequest): assert isinstance(response, commit_response.CommitResponse) -def test_commit_from_dict(): - test_commit(request_type=dict) - - def test_commit_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. @@ -2723,7 +2677,8 @@ async def test_commit_flattened_error_async(): ) -def test_rollback(transport: str = "grpc", request_type=spanner.RollbackRequest): +@pytest.mark.parametrize("request_type", [spanner.RollbackRequest, dict,]) +def test_rollback(request_type, transport: str = "grpc"): client = SpannerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2747,10 +2702,6 @@ def test_rollback(transport: str = "grpc", request_type=spanner.RollbackRequest) assert response is None -def test_rollback_from_dict(): - test_rollback(request_type=dict) - - def test_rollback_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. @@ -2927,9 +2878,8 @@ async def test_rollback_flattened_error_async(): ) -def test_partition_query( - transport: str = "grpc", request_type=spanner.PartitionQueryRequest -): +@pytest.mark.parametrize("request_type", [spanner.PartitionQueryRequest, dict,]) +def test_partition_query(request_type, transport: str = "grpc"): client = SpannerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2953,10 +2903,6 @@ def test_partition_query( assert isinstance(response, spanner.PartitionResponse) -def test_partition_query_from_dict(): - test_partition_query(request_type=dict) - - def test_partition_query_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. @@ -3057,9 +3003,8 @@ async def test_partition_query_field_headers_async(): assert ("x-goog-request-params", "session=session/value",) in kw["metadata"] -def test_partition_read( - transport: str = "grpc", request_type=spanner.PartitionReadRequest -): +@pytest.mark.parametrize("request_type", [spanner.PartitionReadRequest, dict,]) +def test_partition_read(request_type, transport: str = "grpc"): client = SpannerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3083,10 +3028,6 @@ def test_partition_read( assert isinstance(response, spanner.PartitionResponse) -def test_partition_read_from_dict(): - test_partition_read(request_type=dict) - - def test_partition_read_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. @@ -3736,7 +3677,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(