@@ -50,6 +50,7 @@ def test_initialize_readonly(self, mock_build, mock_return_cred):
50
50
51
51
mock_cred = mock .Mock ()
52
52
mock_http = mock .Mock ()
53
+ mock_service_url = mock .Mock ()
53
54
mock_cred .return_value .authorize .return_value = mock_http
54
55
mock_bq = mock .Mock ()
55
56
mock_build .return_value = mock_bq
@@ -59,14 +60,16 @@ def test_initialize_readonly(self, mock_build, mock_return_cred):
59
60
mock_return_cred .return_value = mock_cred
60
61
61
62
bq_client = client .get_client (
62
- project_id , service_account = service_account , private_key = key ,
63
+ project_id , service_url = mock_service_url ,
64
+ service_account = service_account , private_key = key ,
63
65
readonly = True )
64
66
65
67
mock_return_cred .assert_called_once_with ()
66
68
mock_cred .assert_called_once_with (service_account , key ,
67
69
scope = BIGQUERY_SCOPE_READ_ONLY )
68
70
self .assertTrue (mock_cred .return_value .authorize .called )
69
- mock_build .assert_called_once_with ('bigquery' , 'v2' , http = mock_http )
71
+ mock_build .assert_called_once_with ('bigquery' , 'v2' , http = mock_http ,
72
+ discoveryServiceUrl = mock_service_url )
70
73
self .assertEquals (mock_bq , bq_client .bigquery )
71
74
self .assertEquals (project_id , bq_client .project_id )
72
75
@@ -80,6 +83,7 @@ def test_initialize_read_write(self, mock_build, mock_return_cred):
80
83
81
84
mock_cred = mock .Mock ()
82
85
mock_http = mock .Mock ()
86
+ mock_service_url = mock .Mock ()
83
87
mock_cred .return_value .authorize .return_value = mock_http
84
88
mock_bq = mock .Mock ()
85
89
mock_build .return_value = mock_bq
@@ -89,14 +93,16 @@ def test_initialize_read_write(self, mock_build, mock_return_cred):
89
93
mock_return_cred .return_value = mock_cred
90
94
91
95
bq_client = client .get_client (
92
- project_id , service_account = service_account , private_key = key ,
96
+ project_id , service_url = mock_service_url ,
97
+ service_account = service_account , private_key = key ,
93
98
readonly = False )
94
99
95
100
mock_return_cred .assert_called_once_with ()
96
101
mock_cred .assert_called_once_with (service_account , key ,
97
102
scope = BIGQUERY_SCOPE )
98
103
self .assertTrue (mock_cred .return_value .authorize .called )
99
- mock_build .assert_called_once_with ('bigquery' , 'v2' , http = mock_http )
104
+ mock_build .assert_called_once_with ('bigquery' , 'v2' , http = mock_http ,
105
+ discoveryServiceUrl = mock_service_url )
100
106
self .assertEquals (mock_bq , bq_client .bigquery )
101
107
self .assertEquals (project_id , bq_client .project_id )
102
108
@@ -112,6 +118,7 @@ def test_initialize_key_file(self, mock_open, mock_build,
112
118
113
119
mock_cred = mock .Mock ()
114
120
mock_http = mock .Mock ()
121
+ mock_service_url = mock .Mock ()
115
122
mock_cred .return_value .authorize .return_value = mock_http
116
123
mock_bq = mock .Mock ()
117
124
mock_build .return_value = mock_bq
@@ -123,15 +130,17 @@ def test_initialize_key_file(self, mock_open, mock_build,
123
130
mock_return_cred .return_value = mock_cred
124
131
125
132
bq_client = client .get_client (
126
- project_id , service_account = service_account ,
133
+ project_id , service_url = mock_service_url ,
134
+ service_account = service_account ,
127
135
private_key_file = key_file , readonly = False )
128
136
129
137
mock_open .assert_called_once_with (key_file , 'rb' )
130
138
mock_return_cred .assert_called_once_with ()
131
139
mock_cred .assert_called_once_with (service_account , key ,
132
140
scope = BIGQUERY_SCOPE )
133
141
self .assertTrue (mock_cred .return_value .authorize .called )
134
- mock_build .assert_called_once_with ('bigquery' , 'v2' , http = mock_http )
142
+ mock_build .assert_called_once_with ('bigquery' , 'v2' , http = mock_http ,
143
+ discoveryServiceUrl = mock_service_url )
135
144
self .assertEquals (mock_bq , bq_client .bigquery )
136
145
self .assertEquals (project_id , bq_client .project_id )
137
146
@@ -147,6 +156,7 @@ def test_initialize_json_key_file(self, mock_open, mock_build, mock_return_cred)
147
156
148
157
mock_cred = mock .Mock ()
149
158
mock_http = mock .Mock ()
159
+ mock_service_url = mock .Mock ()
150
160
mock_cred .return_value .authorize .return_value = mock_http
151
161
mock_bq = mock .Mock ()
152
162
mock_build .return_value = mock_bq
@@ -156,13 +166,14 @@ def test_initialize_json_key_file(self, mock_open, mock_build, mock_return_cred)
156
166
project_id = 'project'
157
167
mock_return_cred .return_value = mock_cred
158
168
159
- bq_client = client .get_client (project_id , json_key_file = json_key_file , readonly = False )
169
+ bq_client = client .get_client (
170
+ project_id , service_url = mock_service_url , json_key_file = json_key_file , readonly = False )
160
171
161
172
mock_open .assert_called_once_with (json_key_file , 'r' )
162
173
mock_return_cred .assert_called_once_with ()
163
174
mock_cred .assert_called_once_with (json_key ['client_email' ], json_key ['private_key' ], scope = BIGQUERY_SCOPE )
164
175
self .assertTrue (mock_cred .return_value .authorize .called )
165
- mock_build .assert_called_once_with ('bigquery' , 'v2' , http = mock_http )
176
+ mock_build .assert_called_once_with ('bigquery' , 'v2' , http = mock_http , discoveryServiceUrl = mock_service_url )
166
177
self .assertEquals (mock_bq , bq_client .bigquery )
167
178
self .assertEquals (project_id , bq_client .project_id )
168
179
0 commit comments