@@ -27,34 +27,32 @@ def _invoke_client_factory(self, client_class):
2727 return _create_gapic_client (client_class )
2828
2929 def test_without_emulator (self ):
30- from google .cloud .bigtable .client import _CLIENT_INFO
31-
3230 client_class = mock .Mock ()
3331 credentials = _make_credentials ()
3432 client = _Client (credentials )
33+ client_info = client ._client_info = mock .Mock ()
3534
3635 result = self ._invoke_client_factory (client_class )(client )
3736
3837 self .assertIs (result , client_class .return_value )
3938 client_class .assert_called_once_with (
40- credentials = client ._credentials , client_info = _CLIENT_INFO
39+ credentials = client ._credentials , client_info = client_info
4140 )
4241
4342 def test_with_emulator (self ):
44- from google .cloud .bigtable .client import _CLIENT_INFO
45-
4643 client_class = mock .Mock ()
4744 emulator_host = emulator_channel = object ()
4845 credentials = _make_credentials ()
4946 client = _Client (
5047 credentials , emulator_host = emulator_host , emulator_channel = emulator_channel
5148 )
49+ client_info = client ._client_info = mock .Mock ()
5250
5351 result = self ._invoke_client_factory (client_class )(client )
5452
5553 self .assertIs (result , client_class .return_value )
5654 client_class .assert_called_once_with (
57- channel = client ._emulator_channel , client_info = _CLIENT_INFO
55+ channel = client ._emulator_channel , client_info = client_info
5856 )
5957
6058
@@ -82,6 +80,7 @@ def _make_one(self, *args, **kwargs):
8280 return self ._get_target_class ()(* args , ** kwargs )
8381
8482 def test_constructor_defaults (self ):
83+ from google .cloud .bigtable .client import _CLIENT_INFO
8584 from google .cloud .bigtable .client import DATA_SCOPE
8685
8786 credentials = _make_credentials ()
@@ -94,6 +93,7 @@ def test_constructor_defaults(self):
9493 self .assertIs (client ._credentials , credentials .with_scopes .return_value )
9594 self .assertFalse (client ._read_only )
9695 self .assertFalse (client ._admin )
96+ self .assertIs (client ._client_info , _CLIENT_INFO )
9797 self .assertIsNone (client ._channel )
9898 self .assertIsNone (client ._emulator_host )
9999 self .assertIsNone (client ._emulator_channel )
@@ -105,13 +105,15 @@ def test_constructor_explicit(self):
105105 from google .cloud .bigtable .client import DATA_SCOPE
106106
107107 credentials = _make_credentials ()
108+ client_info = mock .Mock ()
108109
109110 with warnings .catch_warnings (record = True ) as warned :
110111 client = self ._make_one (
111112 project = self .PROJECT ,
112113 credentials = credentials ,
113114 read_only = False ,
114115 admin = True ,
116+ client_info = client_info ,
115117 channel = mock .sentinel .channel ,
116118 )
117119
@@ -121,6 +123,7 @@ def test_constructor_explicit(self):
121123 self .assertIs (client ._credentials , credentials .with_scopes .return_value )
122124 self .assertFalse (client ._read_only )
123125 self .assertTrue (client ._admin )
126+ self .assertIs (client ._client_info , client_info )
124127 self .assertIs (client ._channel , mock .sentinel .channel )
125128 self .assertEqual (client .SCOPE , (DATA_SCOPE , ADMIN_SCOPE ))
126129
@@ -182,13 +185,29 @@ def test_project_path_property(self):
182185 self .assertEqual (client .project_path , project_name )
183186
184187 def test_table_data_client_not_initialized (self ):
188+ from google .cloud .bigtable .client import _CLIENT_INFO
185189 from google .cloud .bigtable_v2 import BigtableClient
186190
187191 credentials = _make_credentials ()
188192 client = self ._make_one (project = self .PROJECT , credentials = credentials )
189193
190194 table_data_client = client .table_data_client
191195 self .assertIsInstance (table_data_client , BigtableClient )
196+ self .assertIs (table_data_client ._client_info , _CLIENT_INFO )
197+ self .assertIs (client ._table_data_client , table_data_client )
198+
199+ def test_table_data_client_not_initialized_w_client_info (self ):
200+ from google .cloud .bigtable_v2 import BigtableClient
201+
202+ credentials = _make_credentials ()
203+ client_info = mock .Mock ()
204+ client = self ._make_one (
205+ project = self .PROJECT , credentials = credentials , client_info = client_info
206+ )
207+
208+ table_data_client = client .table_data_client
209+ self .assertIsInstance (table_data_client , BigtableClient )
210+ self .assertIs (table_data_client ._client_info , client_info )
192211 self .assertIs (client ._table_data_client , table_data_client )
193212
194213 def test_table_data_client_initialized (self ):
@@ -208,6 +227,7 @@ def test_table_admin_client_not_initialized_no_admin_flag(self):
208227 client .table_admin_client ()
209228
210229 def test_table_admin_client_not_initialized_w_admin_flag (self ):
230+ from google .cloud .bigtable .client import _CLIENT_INFO
211231 from google .cloud .bigtable_admin_v2 import BigtableTableAdminClient
212232
213233 credentials = _make_credentials ()
@@ -217,6 +237,25 @@ def test_table_admin_client_not_initialized_w_admin_flag(self):
217237
218238 table_admin_client = client .table_admin_client
219239 self .assertIsInstance (table_admin_client , BigtableTableAdminClient )
240+ self .assertIs (table_admin_client ._client_info , _CLIENT_INFO )
241+ self .assertIs (client ._table_admin_client , table_admin_client )
242+
243+ def test_table_admin_client_not_initialized_w_client_info (self ):
244+ from google .cloud .bigtable_admin_v2 import BigtableTableAdminClient
245+
246+ credentials = _make_credentials ()
247+ client_info = mock .Mock ()
248+ client = self ._make_one (
249+ project = self .PROJECT ,
250+ credentials = credentials ,
251+ admin = True ,
252+ client_info = client_info ,
253+ )
254+
255+ table_admin_client = client .table_admin_client
256+ self .assertIsInstance (table_admin_client , BigtableTableAdminClient )
257+ self .assertIs (table_admin_client ._client_info , client_info )
258+ self .assertIs (client ._table_admin_client , table_admin_client )
220259
221260 def test_table_admin_client_initialized (self ):
222261 credentials = _make_credentials ()
@@ -235,6 +274,7 @@ def test_instance_admin_client_not_initialized_no_admin_flag(self):
235274 client .instance_admin_client ()
236275
237276 def test_instance_admin_client_not_initialized_w_admin_flag (self ):
277+ from google .cloud .bigtable .client import _CLIENT_INFO
238278 from google .cloud .bigtable_admin_v2 import BigtableInstanceAdminClient
239279
240280 credentials = _make_credentials ()
@@ -244,6 +284,25 @@ def test_instance_admin_client_not_initialized_w_admin_flag(self):
244284
245285 instance_admin_client = client .instance_admin_client
246286 self .assertIsInstance (instance_admin_client , BigtableInstanceAdminClient )
287+ self .assertIs (instance_admin_client ._client_info , _CLIENT_INFO )
288+ self .assertIs (client ._instance_admin_client , instance_admin_client )
289+
290+ def test_instance_admin_client_not_initialized_w_admin_and_client_info (self ):
291+ from google .cloud .bigtable_admin_v2 import BigtableInstanceAdminClient
292+
293+ credentials = _make_credentials ()
294+ client_info = mock .Mock ()
295+ client = self ._make_one (
296+ project = self .PROJECT ,
297+ credentials = credentials ,
298+ admin = True ,
299+ client_info = client_info ,
300+ )
301+
302+ instance_admin_client = client .instance_admin_client
303+ self .assertIsInstance (instance_admin_client , BigtableInstanceAdminClient )
304+ self .assertIs (instance_admin_client ._client_info , client_info )
305+ self .assertIs (client ._instance_admin_client , instance_admin_client )
247306
248307 def test_instance_admin_client_initialized (self ):
249308 credentials = _make_credentials ()
0 commit comments