2626from google .cloud .sql .connector import create_async_connector
2727from google .cloud .sql .connector import IPTypes
2828from google .cloud .sql .connector .client import CloudSQLClient
29+ from google .cloud .sql .connector .connection_name import ConnectionName
2930from google .cloud .sql .connector .exceptions import CloudSQLIPTypeError
3031from google .cloud .sql .connector .exceptions import IncompatibleDriverError
3132from google .cloud .sql .connector .instance import RefreshAheadCache
@@ -322,18 +323,18 @@ async def test_Connector_remove_cached_bad_instance(
322323 async with Connector (
323324 credentials = fake_credentials , loop = asyncio .get_running_loop ()
324325 ) as connector :
325- conn_name = "bad-project: bad-region: bad-inst"
326+ conn_name = ConnectionName ( "bad-project" , " bad-region" , " bad-inst")
326327 # populate cache
327328 cache = RefreshAheadCache (conn_name , fake_client , connector ._keys )
328- connector ._cache [(conn_name , False )] = cache
329+ connector ._cache [(str ( conn_name ) , False )] = cache
329330 # aiohttp client should throw a 404 ClientResponseError
330331 with pytest .raises (ClientResponseError ):
331332 await connector .connect_async (
332- conn_name ,
333+ str ( conn_name ) ,
333334 "pg8000" ,
334335 )
335336 # check that cache has been removed from dict
336- assert (conn_name , False ) not in connector ._cache
337+ assert (str ( conn_name ) , False ) not in connector ._cache
337338
338339
339340async def test_Connector_remove_cached_no_ip_type (
@@ -348,21 +349,21 @@ async def test_Connector_remove_cached_no_ip_type(
348349 async with Connector (
349350 credentials = fake_credentials , loop = asyncio .get_running_loop ()
350351 ) as connector :
351- conn_name = "test-project: test-region: test-instance"
352+ conn_name = ConnectionName ( "test-project" , " test-region" , " test-instance")
352353 # populate cache
353354 cache = RefreshAheadCache (conn_name , fake_client , connector ._keys )
354- connector ._cache [(conn_name , False )] = cache
355+ connector ._cache [(str ( conn_name ) , False )] = cache
355356 # test instance does not have Private IP, thus should invalidate cache
356357 with pytest .raises (CloudSQLIPTypeError ):
357358 await connector .connect_async (
358- conn_name ,
359+ str ( conn_name ) ,
359360 "pg8000" ,
360361 user = "my-user" ,
361362 password = "my-pass" ,
362363 ip_type = "private" ,
363364 )
364365 # check that cache has been removed from dict
365- assert (conn_name , False ) not in connector ._cache
366+ assert (str ( conn_name ) , False ) not in connector ._cache
366367
367368
368369def test_default_universe_domain (fake_credentials : Credentials ) -> None :
0 commit comments