@@ -90,6 +90,10 @@ def test_ctor(self):
9090 def test_ctor_super_inits (self ):
9191 from google .cloud .client import ClientWithProject
9292 from google .api_core import client_options as client_options_lib
93+ from google .cloud .bigtable_v2 .services .bigtable .transports .base import (
94+ DEFAULT_CLIENT_INFO ,
95+ )
96+ import copy
9397
9498 project = "project-id"
9599 credentials = AnonymousCredentials ()
@@ -116,12 +120,64 @@ def test_ctor_super_inits(self):
116120 kwargs = bigtable_client_init .call_args [1 ]
117121 assert kwargs ["credentials" ] == credentials
118122 assert kwargs ["client_options" ] == options_parsed
123+ expected_client_info = copy .copy (DEFAULT_CLIENT_INFO )
124+ expected_client_info .client_library_version = (
125+ CrossSync ._Sync_Impl .DataClient ._client_version ()
126+ )
127+ assert (
128+ kwargs ["client_info" ].to_user_agent ()
129+ == expected_client_info .to_user_agent ()
130+ )
131+ assert (
132+ kwargs ["client_info" ].to_grpc_metadata ()
133+ == expected_client_info .to_grpc_metadata ()
134+ )
119135 assert client_project_init .call_count == 1
120136 kwargs = client_project_init .call_args [1 ]
121137 assert kwargs ["project" ] == project
122138 assert kwargs ["credentials" ] == credentials
123139 assert kwargs ["client_options" ] == options_parsed
124140
141+ def test_ctor_client_info (self ):
142+ from google .api_core import client_options as client_options_lib
143+ from google .api_core .gapic_v1 .client_info import ClientInfo
144+ import copy
145+
146+ project = "project-id"
147+ credentials = AnonymousCredentials ()
148+ client_info = ClientInfo (gapic_version = "1.2.3" , user_agent = "test-client-" )
149+ client_options = {"api_endpoint" : "foo.bar:1234" }
150+ options_parsed = client_options_lib .from_dict (client_options )
151+ with mock .patch .object (
152+ CrossSync ._Sync_Impl .GapicClient , "__init__"
153+ ) as bigtable_client_init :
154+ try :
155+ self ._make_client (
156+ project = project ,
157+ credentials = credentials ,
158+ client_info = client_info ,
159+ client_options = options_parsed ,
160+ use_emulator = False ,
161+ )
162+ except TypeError :
163+ pass
164+ assert bigtable_client_init .call_count == 1
165+ kwargs = bigtable_client_init .call_args [1 ]
166+ assert kwargs ["credentials" ] == credentials
167+ assert kwargs ["client_options" ] == options_parsed
168+ expected_client_info = copy .copy (client_info )
169+ expected_client_info .client_library_version = (
170+ CrossSync ._Sync_Impl .DataClient ._client_version ()
171+ )
172+ assert (
173+ kwargs ["client_info" ].to_user_agent ()
174+ == expected_client_info .to_user_agent ()
175+ )
176+ assert (
177+ kwargs ["client_info" ].to_grpc_metadata ()
178+ == expected_client_info .to_grpc_metadata ()
179+ )
180+
125181 def test_ctor_dict_options (self ):
126182 from google .api_core .client_options import ClientOptions
127183
@@ -194,6 +250,20 @@ def test__start_background_channel_refresh(self):
194250 assert ping_and_warm .call_count == 1
195251 client .close ()
196252
253+ def test__start_background_channel_refresh_disable_refresh (self ):
254+ client = self ._make_client (
255+ project = "project-id" , disable_background_channel_refresh = True
256+ )
257+ with mock .patch .object (
258+ client , "_ping_and_warm_instances" , CrossSync ._Sync_Impl .Mock ()
259+ ):
260+ client ._emulator_host = None
261+ client .transport ._grpc_channel = CrossSync ._Sync_Impl .SwappableChannel (
262+ mock .Mock
263+ )
264+ client ._start_background_channel_refresh ()
265+ assert client ._channel_refresh_task is None
266+
197267 def test__ping_and_warm_instances (self ):
198268 """test ping and warm with mocked asyncio.gather"""
199269 client_mock = mock .Mock ()
0 commit comments