13
13
# limitations under the License.
14
14
15
15
import re
16
+ from unittest import mock
16
17
import warnings
17
18
19
+ import google .auth .credentials
18
20
import pytest
19
21
20
22
import bigframes
35
37
("kms_key_name" , "kms/key/name/1" , "kms/key/name/2" ),
36
38
("skip_bq_connection_check" , False , True ),
37
39
("client_endpoints_override" , {}, {"bqclient" : "endpoint_address" }),
40
+ ("ordering_mode" , "strict" , "partial" ),
38
41
],
39
42
)
40
43
def 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):
57
60
@pytest .mark .parametrize (
58
61
[
59
62
"attribute" ,
63
+ "original_value" ,
60
64
],
61
65
[
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" ),
73
75
],
74
76
)
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
+ ):
76
80
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
80
83
81
84
# This should work fine since we're setting the same value as before.
82
85
options ._session_started = True
83
- setattr (options , attribute , original_object )
86
+ setattr (options , attribute , original_value )
87
+
88
+ assert getattr (options , attribute ) == original_value
84
89
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
86
103
87
104
88
105
@pytest .mark .parametrize (
0 commit comments