2323
2424import pytest
2525from typing import Any , List
26+ from ...helpers import warn_deprecated_credentials_file
2627
2728try :
2829 import grpc # noqa: F401
@@ -369,7 +370,8 @@ def test_operations_client_client_options(
369370 )
370371
371372 # Check the case credentials_file is provided
372- options = client_options .ClientOptions (credentials_file = "credentials.json" )
373+ with warn_deprecated_credentials_file ():
374+ options = client_options .ClientOptions (credentials_file = "credentials.json" )
373375 with mock .patch .object (transport_class , "__init__" ) as patched :
374376 patched .return_value = None
375377 client = client_class (client_options = options , transport = transport_name )
@@ -539,11 +541,14 @@ def test_operations_client_client_options_credentials_file(
539541 client_class , transport_class , transport_name
540542):
541543 # Check the case credentials file is provided.
542- options = client_options .ClientOptions (credentials_file = "credentials.json" )
544+ with warn_deprecated_credentials_file ():
545+ options = client_options .ClientOptions (credentials_file = "credentials.json" )
543546 if "async" in str (client_class ):
544547 # TODO(): Add support for credentials file to async REST transport.
545548 with pytest .raises (core_exceptions .AsyncRestUnsupportedParameterError ):
546- client_class (client_options = options , transport = transport_name )
549+ with warn_deprecated_credentials_file ():
550+
551+ client_class (client_options = options , transport = transport_name )
547552 else :
548553 with mock .patch .object (transport_class , "__init__" ) as patched :
549554 patched .return_value = None
@@ -570,10 +575,18 @@ def test_operations_client_client_options_credentials_file(
570575 return_value = (mock .sentinel .credentials , mock .sentinel .project ),
571576)
572577def test_list_operations_rest (google_auth_default , credentials_file ):
573- sync_transport = transports .rest .OperationsRestTransport (
574- credentials_file = credentials_file ,
575- http_options = HTTP_OPTIONS ,
576- )
578+ if credentials_file :
579+ with warn_deprecated_credentials_file ():
580+ sync_transport = transports .rest .OperationsRestTransport (
581+ credentials_file = credentials_file ,
582+ http_options = HTTP_OPTIONS ,
583+ )
584+ else :
585+ # no warning expected
586+ sync_transport = transports .rest .OperationsRestTransport (
587+ credentials_file = credentials_file ,
588+ http_options = HTTP_OPTIONS ,
589+ )
577590
578591 client = AbstractOperationsClient (transport = sync_transport )
579592
@@ -1130,10 +1143,11 @@ def test_transport_adc(client_class, transport_class, credentials):
11301143def test_operations_base_transport_error ():
11311144 # Passing both a credentials object and credentials_file should raise an error
11321145 with pytest .raises (core_exceptions .DuplicateCredentialArgs ):
1133- transports .OperationsTransport (
1134- credentials = ga_credentials .AnonymousCredentials (),
1135- credentials_file = "credentials.json" ,
1136- )
1146+ with warn_deprecated_credentials_file ():
1147+ transports .OperationsTransport (
1148+ credentials = ga_credentials .AnonymousCredentials (),
1149+ credentials_file = "credentials.json" ,
1150+ )
11371151
11381152
11391153def test_operations_base_transport ():
@@ -1171,10 +1185,11 @@ def test_operations_base_transport_with_credentials_file():
11711185 ) as Transport :
11721186 Transport .return_value = None
11731187 load_creds .return_value = (ga_credentials .AnonymousCredentials (), None )
1174- transports .OperationsTransport (
1175- credentials_file = "credentials.json" ,
1176- quota_project_id = "octopus" ,
1177- )
1188+ with warn_deprecated_credentials_file ():
1189+ transports .OperationsTransport (
1190+ credentials_file = "credentials.json" ,
1191+ quota_project_id = "octopus" ,
1192+ )
11781193 load_creds .assert_called_once_with (
11791194 "credentials.json" ,
11801195 scopes = None ,
0 commit comments