Summary
ClickHouseQueryActivityTool and ClickHouseSystemHealthTool have no unit tests. An integration test at tests/integrations/test_clickhouse.py covers config validation, but tool-level behaviour is untested.
Context
Both tools delegate to app/integrations/clickhouse.py (get_query_activity, get_system_health) and use a shared config model ClickHouseConfig plus clickhouse_is_available and clickhouse_extract_params helpers. The ClickHouse client (clickhouse_connect) is imported lazily — no live instance needed in tests.
What to implement
Create two files:
tests/tools/test_clickhouse_query_activity_tool.py
tests/tools/test_clickhouse_system_health_tool.py
Each should cover:
- Contract test — inherit
BaseToolContract from tests/tools/conftest.py
is_available — True when sources["clickhouse"] has host and connection_verified: True; False otherwise
extract_params — assert host, port, database, username, limit are mapped correctly from sources
run happy path — patch app.integrations.clickhouse.get_query_activity (or get_system_health) with a MagicMock and assert the tool returns available: True with the expected structure
run error path — patch to raise an exception (e.g., Exception("connection refused")) and verify a graceful error dict is returned
Acceptance criteria
References
- Pattern:
tests/tools/test_elasticsearch_logs_tool.py (closest analogue — similar structure)
- Tool sources:
app/tools/ClickHouseQueryActivityTool/, app/tools/ClickHouseSystemHealthTool/
- Integration helpers:
app/integrations/clickhouse.py
- Existing integration test:
tests/integrations/test_clickhouse.py
Summary
ClickHouseQueryActivityToolandClickHouseSystemHealthToolhave no unit tests. An integration test attests/integrations/test_clickhouse.pycovers config validation, but tool-level behaviour is untested.Context
Both tools delegate to
app/integrations/clickhouse.py(get_query_activity,get_system_health) and use a shared config modelClickHouseConfigplusclickhouse_is_availableandclickhouse_extract_paramshelpers. The ClickHouse client (clickhouse_connect) is imported lazily — no live instance needed in tests.What to implement
Create two files:
tests/tools/test_clickhouse_query_activity_tool.pytests/tools/test_clickhouse_system_health_tool.pyEach should cover:
BaseToolContractfromtests/tools/conftest.pyis_available—Truewhensources["clickhouse"]hashostandconnection_verified: True;Falseotherwiseextract_params— asserthost,port,database,username,limitare mapped correctly from sourcesrunhappy path — patchapp.integrations.clickhouse.get_query_activity(orget_system_health) with aMagicMockand assert the tool returnsavailable: Truewith the expected structurerunerror path — patch to raise an exception (e.g.,Exception("connection refused")) and verify a graceful error dict is returnedAcceptance criteria
tests/tools/make test-covpassesmake lintpassesReferences
tests/tools/test_elasticsearch_logs_tool.py(closest analogue — similar structure)app/tools/ClickHouseQueryActivityTool/,app/tools/ClickHouseSystemHealthTool/app/integrations/clickhouse.pytests/integrations/test_clickhouse.py