Skip to content

Commit 0b14cb3

Browse files
[async] Applied #2596 to async code - part 4 - proxies tests working
1 parent 59601fa commit 0b14cb3

File tree

3 files changed

+400
-57
lines changed

3 files changed

+400
-57
lines changed

test/test_utils/cross_module_fixtures/http_fixtures.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
import pytest
44

5+
from snowflake.connector.compat import urlparse as compat_urlparse
6+
from snowflake.connector.session_manager import SessionManager
7+
58

69
@pytest.fixture
710
def proxy_env_vars():
@@ -42,3 +45,23 @@ def clear_proxy_env_vars():
4245
os.environ["NO_PROXY"] = original_no_proxy
4346
elif "NO_PROXY" in os.environ:
4447
del os.environ["NO_PROXY"]
48+
49+
50+
@pytest.fixture
51+
def host_port_pooling(monkeypatch):
52+
53+
def get_pooling_key_as_host_with_port(url: str) -> str:
54+
"""
55+
Test-only override to derive pooling key as "host:port" if port is specified.
56+
"""
57+
parsed = compat_urlparse(url)
58+
host = parsed.hostname
59+
port = parsed.port
60+
return f"{host}:{port}" if port else host
61+
62+
monkeypatch.setattr(
63+
SessionManager,
64+
"_get_pooling_key_from_url",
65+
staticmethod(get_pooling_key_as_host_with_port),
66+
)
67+
yield

0 commit comments

Comments
 (0)