diff --git a/shared/python/ja4_common/tests/test_clickhouse.py b/shared/python/ja4_common/tests/test_clickhouse.py index c0d95ae..7f65310 100644 --- a/shared/python/ja4_common/tests/test_clickhouse.py +++ b/shared/python/ja4_common/tests/test_clickhouse.py @@ -26,17 +26,15 @@ def test_client_reconnects_on_ping_fail(): def test_get_client_returns_same_instance_on_second_call(): - """get_client() is a singleton: returns the same object on repeated calls.""" + """get_client() is a singleton: returns the same ClickHouseClient wrapper on repeated calls. + Note: clickhouse_connect.get_client is only called lazily on .connect(), not on get_client(). + """ + ch_module._client = None + c1 = get_client() + c2 = get_client() + assert c1 is c2 + # Reset for other tests ch_module._client = None - with patch("ja4_common.clickhouse.clickhouse_connect.get_client") as mock_gc: - mock_inner = MagicMock() - mock_inner.ping.return_value = True - mock_gc.return_value = mock_inner - c1 = get_client() - c2 = get_client() - assert c1 is c2 - # connect() should have been called once for c1; c2 reuses the same instance - assert mock_gc.call_count == 1 def test_client_query_delegates_to_inner():