1313# limitations under the License.
1414
1515import re
16+ from unittest import mock
1617import warnings
1718
19+ import google .auth .credentials
1820import pytest
1921
2022import bigframes
3537 ("kms_key_name" , "kms/key/name/1" , "kms/key/name/2" ),
3638 ("skip_bq_connection_check" , False , True ),
3739 ("client_endpoints_override" , {}, {"bqclient" : "endpoint_address" }),
40+ ("ordering_mode" , "strict" , "partial" ),
3841 ],
3942)
4043def test_setter_raises_if_session_started (attribute , original_value , new_value ):
@@ -57,32 +60,46 @@ def test_setter_raises_if_session_started(attribute, original_value, new_value):
5760@pytest .mark .parametrize (
5861 [
5962 "attribute" ,
63+ "original_value" ,
6064 ],
6165 [
62- (attribute ,)
63- for attribute in [
64- "application_name" ,
65- "credentials" ,
66- "location" ,
67- "project" ,
68- "bq_connection" ,
69- "use_regional_endpoints" ,
70- "bq_kms_key_name" ,
71- "client_endpoints_override" ,
72- ]
66+ ("application_name" , "test-partner" ),
67+ ("location" , "us-east1" ),
68+ ("project" , "my-project" ),
69+ ("bq_connection" , "path/to/connection/1" ),
70+ ("use_regional_endpoints" , True ),
71+ ("kms_key_name" , "kms/key/name/1" ),
72+ ("skip_bq_connection_check" , True ),
73+ ("client_endpoints_override" , {"bqclient" : "endpoint_address" }),
74+ ("ordering_mode" , "partial" ),
7375 ],
7476)
75- def test_setter_if_session_started_but_setting_the_same_value (attribute ):
77+ def test_setter_if_session_started_but_setting_the_same_value (
78+ attribute , original_value
79+ ):
7680 options = bigquery_options .BigQueryOptions ()
77- original_object = object ()
78- setattr (options , attribute , original_object )
79- assert getattr (options , attribute ) is original_object
81+ setattr (options , attribute , original_value )
82+ assert getattr (options , attribute ) == original_value
8083
8184 # This should work fine since we're setting the same value as before.
8285 options ._session_started = True
83- setattr (options , attribute , original_object )
86+ setattr (options , attribute , original_value )
87+
88+ assert getattr (options , attribute ) == original_value
8489
85- assert getattr (options , attribute ) is original_object
90+
91+ def test_setter_if_session_started_but_setting_the_same_credentials_object ():
92+ options = bigquery_options .BigQueryOptions ()
93+ original_object = mock .create_autospec (
94+ google .auth .credentials .Credentials , instance = True
95+ )
96+ options .credentials = original_object
97+ assert options .credentials is original_object
98+
99+ # This should work fine since we're setting the same value as before.
100+ options ._session_started = True
101+ options .credentials = original_object
102+ assert options .credentials is original_object
86103
87104
88105@pytest .mark .parametrize (
0 commit comments