21
21
22
22
23
23
class Test__create_gapic_client (unittest .TestCase ):
24
- def _invoke_client_factory (self , client_class ):
24
+ def _invoke_client_factory (self , client_class , ** kw ):
25
25
from google .cloud .bigtable .client import _create_gapic_client
26
26
27
- return _create_gapic_client (client_class )
27
+ return _create_gapic_client (client_class , ** kw )
28
28
29
- def test_without_emulator (self ):
29
+ def test_wo_emulator (self ):
30
30
client_class = mock .Mock ()
31
31
credentials = _make_credentials ()
32
32
client = _Client (credentials )
@@ -36,10 +36,30 @@ def test_without_emulator(self):
36
36
37
37
self .assertIs (result , client_class .return_value )
38
38
client_class .assert_called_once_with (
39
- credentials = client ._credentials , client_info = client_info
39
+ credentials = client ._credentials ,
40
+ client_info = client_info ,
41
+ client_options = None ,
40
42
)
41
43
42
- def test_with_emulator (self ):
44
+ def test_wo_emulator_w_client_options (self ):
45
+ client_class = mock .Mock ()
46
+ credentials = _make_credentials ()
47
+ client = _Client (credentials )
48
+ client_info = client ._client_info = mock .Mock ()
49
+ client_options = mock .Mock ()
50
+
51
+ result = self ._invoke_client_factory (
52
+ client_class , client_options = client_options
53
+ )(client )
54
+
55
+ self .assertIs (result , client_class .return_value )
56
+ client_class .assert_called_once_with (
57
+ credentials = client ._credentials ,
58
+ client_info = client_info ,
59
+ client_options = client_options ,
60
+ )
61
+
62
+ def test_w_emulator (self ):
43
63
client_class = mock .Mock ()
44
64
emulator_host = emulator_channel = object ()
45
65
credentials = _make_credentials ()
@@ -210,6 +230,25 @@ def test_table_data_client_not_initialized_w_client_info(self):
210
230
self .assertIs (table_data_client ._client_info , client_info )
211
231
self .assertIs (client ._table_data_client , table_data_client )
212
232
233
+ def test_table_data_client_not_initialized_w_client_options (self ):
234
+ credentials = _make_credentials ()
235
+ client_options = mock .Mock ()
236
+ client = self ._make_one (
237
+ project = self .PROJECT , credentials = credentials , client_options = client_options
238
+ )
239
+
240
+ patch = mock .patch ("google.cloud.bigtable_v2.BigtableClient" )
241
+ with patch as mocked :
242
+ table_data_client = client .table_data_client
243
+
244
+ self .assertIs (table_data_client , mocked .return_value )
245
+ self .assertIs (client ._table_data_client , table_data_client )
246
+ mocked .assert_called_once_with (
247
+ client_info = client ._client_info ,
248
+ credentials = mock .ANY , # added scopes
249
+ client_options = client_options ,
250
+ )
251
+
213
252
def test_table_data_client_initialized (self ):
214
253
credentials = _make_credentials ()
215
254
client = self ._make_one (
@@ -257,6 +296,28 @@ def test_table_admin_client_not_initialized_w_client_info(self):
257
296
self .assertIs (table_admin_client ._client_info , client_info )
258
297
self .assertIs (client ._table_admin_client , table_admin_client )
259
298
299
+ def test_table_admin_client_not_initialized_w_client_options (self ):
300
+ credentials = _make_credentials ()
301
+ admin_client_options = mock .Mock ()
302
+ client = self ._make_one (
303
+ project = self .PROJECT ,
304
+ credentials = credentials ,
305
+ admin = True ,
306
+ admin_client_options = admin_client_options ,
307
+ )
308
+
309
+ patch = mock .patch ("google.cloud.bigtable_admin_v2.BigtableTableAdminClient" )
310
+ with patch as mocked :
311
+ table_admin_client = client .table_admin_client
312
+
313
+ self .assertIs (table_admin_client , mocked .return_value )
314
+ self .assertIs (client ._table_admin_client , table_admin_client )
315
+ mocked .assert_called_once_with (
316
+ client_info = client ._client_info ,
317
+ credentials = mock .ANY , # added scopes
318
+ client_options = admin_client_options ,
319
+ )
320
+
260
321
def test_table_admin_client_initialized (self ):
261
322
credentials = _make_credentials ()
262
323
client = self ._make_one (
@@ -287,7 +348,7 @@ def test_instance_admin_client_not_initialized_w_admin_flag(self):
287
348
self .assertIs (instance_admin_client ._client_info , _CLIENT_INFO )
288
349
self .assertIs (client ._instance_admin_client , instance_admin_client )
289
350
290
- def test_instance_admin_client_not_initialized_w_admin_and_client_info (self ):
351
+ def test_instance_admin_client_not_initialized_w_client_info (self ):
291
352
from google .cloud .bigtable_admin_v2 import BigtableInstanceAdminClient
292
353
293
354
credentials = _make_credentials ()
@@ -304,6 +365,28 @@ def test_instance_admin_client_not_initialized_w_admin_and_client_info(self):
304
365
self .assertIs (instance_admin_client ._client_info , client_info )
305
366
self .assertIs (client ._instance_admin_client , instance_admin_client )
306
367
368
+ def test_instance_admin_client_not_initialized_w_client_options (self ):
369
+ credentials = _make_credentials ()
370
+ admin_client_options = mock .Mock ()
371
+ client = self ._make_one (
372
+ project = self .PROJECT ,
373
+ credentials = credentials ,
374
+ admin = True ,
375
+ admin_client_options = admin_client_options ,
376
+ )
377
+
378
+ patch = mock .patch ("google.cloud.bigtable_admin_v2.BigtableInstanceAdminClient" )
379
+ with patch as mocked :
380
+ instance_admin_client = client .instance_admin_client
381
+
382
+ self .assertIs (instance_admin_client , mocked .return_value )
383
+ self .assertIs (client ._instance_admin_client , instance_admin_client )
384
+ mocked .assert_called_once_with (
385
+ client_info = client ._client_info ,
386
+ credentials = mock .ANY , # added scopes
387
+ client_options = admin_client_options ,
388
+ )
389
+
307
390
def test_instance_admin_client_initialized (self ):
308
391
credentials = _make_credentials ()
309
392
client = self ._make_one (
0 commit comments