|
33 | 33 | from google.cloud.sql.connector.exceptions import CloudSQLIPTypeError |
34 | 34 | from google.cloud.sql.connector.exceptions import IncompatibleDriverError |
35 | 35 | from google.cloud.sql.connector.instance import RefreshAheadCache |
36 | | -from google.cloud.sql.connector.proxy import start_local_proxy |
| 36 | +# from google.cloud.sql.connector.proxy import start_local_proxy |
37 | 37 |
|
38 | 38 |
|
39 | 39 | @pytest.mark.asyncio |
@@ -282,47 +282,47 @@ async def test_Connector_connect_async( |
282 | 282 | # verify connector made connection call |
283 | 283 | assert connection is True |
284 | 284 |
|
285 | | -@pytest.mark.usefixtures("proxy_server") |
286 | | -@pytest.mark.asyncio |
287 | | -async def test_Connector_connect_local_proxy( |
288 | | - fake_credentials: Credentials, fake_client: CloudSQLClient, context: ssl.SSLContext |
289 | | -) -> None: |
290 | | - """Test that Connector.connect can launch start_local_proxy.""" |
291 | | - async with Connector( |
292 | | - credentials=fake_credentials, loop=asyncio.get_running_loop() |
293 | | - ) as connector: |
294 | | - connector._client = fake_client |
295 | | - socket_path = "/tmp/connector-socket/socket" |
296 | | - ip_addr = "127.0.0.1" |
297 | | - ssl_sock = context.wrap_socket( |
298 | | - socket.create_connection((ip_addr, 3307)), |
299 | | - server_hostname=ip_addr, |
300 | | - ) |
301 | | - loop = asyncio.get_running_loop() |
302 | | - task = start_local_proxy(ssl_sock, socket_path, loop) |
303 | | - # patch db connection creation |
304 | | - with patch("google.cloud.sql.connector.proxy.start_local_proxy") as mock_proxy: |
305 | | - with patch("google.cloud.sql.connector.psycopg.connect") as mock_connect: |
306 | | - mock_connect.return_value = True |
307 | | - mock_proxy.return_value = task |
308 | | - connection = await connector.connect_async( |
309 | | - "test-project:test-region:test-instance", |
310 | | - "psycopg", |
311 | | - user="my-user", |
312 | | - password="my-pass", |
313 | | - db="my-db", |
314 | | - local_socket_path=socket_path, |
315 | | - ) |
316 | | - # verify connector called local proxy |
317 | | - mock_connect.assert_called_once() |
318 | | - mock_proxy.assert_called_once() |
319 | | - assert connection is True |
| 285 | +# @pytest.mark.usefixtures("proxy_server") |
| 286 | +# @pytest.mark.asyncio |
| 287 | +# async def test_Connector_connect_local_proxy( |
| 288 | +# fake_credentials: Credentials, fake_client: CloudSQLClient, context: ssl.SSLContext |
| 289 | +# ) -> None: |
| 290 | +# """Test that Connector.connect can launch start_local_proxy.""" |
| 291 | +# async with Connector( |
| 292 | +# credentials=fake_credentials, loop=asyncio.get_running_loop() |
| 293 | +# ) as connector: |
| 294 | +# connector._client = fake_client |
| 295 | +# socket_path = "/tmp/connector-socket/socket" |
| 296 | +# ip_addr = "127.0.0.1" |
| 297 | +# ssl_sock = context.wrap_socket( |
| 298 | +# socket.create_connection((ip_addr, 3307)), |
| 299 | +# server_hostname=ip_addr, |
| 300 | +# ) |
| 301 | +# loop = asyncio.get_running_loop() |
| 302 | +# task = start_local_proxy(ssl_sock, socket_path, loop) |
| 303 | +# # patch db connection creation |
| 304 | +# with patch("google.cloud.sql.connector.proxy.start_local_proxy") as mock_proxy: |
| 305 | +# with patch("google.cloud.sql.connector.psycopg.connect") as mock_connect: |
| 306 | +# mock_connect.return_value = True |
| 307 | +# mock_proxy.return_value = task |
| 308 | +# connection = await connector.connect_async( |
| 309 | +# "test-project:test-region:test-instance", |
| 310 | +# "psycopg", |
| 311 | +# user="my-user", |
| 312 | +# password="my-pass", |
| 313 | +# db="my-db", |
| 314 | +# local_socket_path=socket_path, |
| 315 | +# ) |
| 316 | +# # verify connector called local proxy |
| 317 | +# mock_connect.assert_called_once() |
| 318 | +# mock_proxy.assert_called_once() |
| 319 | +# assert connection is True |
320 | 320 |
|
321 | | - proxy_task = asyncio.gather(task) |
322 | | - try: |
323 | | - await asyncio.wait_for(proxy_task, timeout=0.1) |
324 | | - except (asyncio.CancelledError, asyncio.TimeoutError, TimeoutError): |
325 | | - pass # This task runs forever so it is expected to throw this exception |
| 321 | +# proxy_task = asyncio.gather(task) |
| 322 | +# try: |
| 323 | +# await asyncio.wait_for(proxy_task, timeout=0.1) |
| 324 | +# except (asyncio.CancelledError, asyncio.TimeoutError, TimeoutError): |
| 325 | +# pass # This task runs forever so it is expected to throw this exception |
326 | 326 |
|
327 | 327 |
|
328 | 328 | @pytest.mark.asyncio |
|
0 commit comments