fix: restore side-effect imports in test files (test_kanban_tools, test_command_guards)

The previous ruff prune commit removed two categories of test-file
imports whose value is the side effect of importing them, not their
binding:

  tests/tools/test_kanban_tools.py — 5 sites
    `import tools.kanban_tools  # ensure registered`
    The import itself runs tools/kanban_tools.py's @registry.register
    calls; without it, the kanban tool registry is empty and
    test_kanban_tools_visible_with_env_var asserts {} != {7 kanban tools}.

  tests/tools/test_command_guards.py — 1 site
    `import tools.tirith_security  # Ensure the module is importable so we can patch it`
    The comment names the requirement: keep the bare module reference
    so subsequent mock.patch("tools.tirith_security.<fn>") calls find
    a registered submodule.

CI failure: test (5) shard, tests/tools/test_kanban_tools.py:58
  AssertionError: expected {kanban_*}, got set()
This commit is contained in:
Teknium 2026-05-28 21:35:19 -07:00
parent e371bf5d68
commit 00b8204cf4
2 changed files with 9 additions and 0 deletions

View file

@ -10,9 +10,12 @@ from tools.approval import (
approve_session,
check_all_command_guards,
is_approved,
set_current_session_key,
reset_current_session_key,
)
# Ensure the module is importable so we can patch it
import tools.tirith_security
# ---------------------------------------------------------------------------

View file

@ -9,6 +9,7 @@ Verifies:
from __future__ import annotations
import json
import os
import pytest
@ -25,6 +26,7 @@ def test_kanban_tools_hidden_without_env_var(monkeypatch, tmp_path):
home.mkdir()
monkeypatch.setenv("HERMES_HOME", str(home))
import tools.kanban_tools # ensure registered
from tools.registry import invalidate_check_fn_cache, registry
from toolsets import resolve_toolset
@ -44,6 +46,7 @@ def test_kanban_tools_visible_with_env_var(monkeypatch, tmp_path):
home.mkdir()
monkeypatch.setenv("HERMES_HOME", str(home))
import tools.kanban_tools # ensure registered
from tools.registry import invalidate_check_fn_cache, registry
from toolsets import resolve_toolset
@ -67,6 +70,7 @@ def test_kanban_worker_env_overrides_profile_toolset_filter(monkeypatch, tmp_pat
home.mkdir()
monkeypatch.setenv("HERMES_HOME", str(home))
import tools.kanban_tools # ensure registered
from model_tools import _clear_tool_defs_cache, get_tool_definitions
from tools.registry import invalidate_check_fn_cache
@ -96,6 +100,7 @@ def test_worker_with_kanban_toolset_still_hides_board_routing(monkeypatch, tmp_p
(home / "config.yaml").write_text("toolsets:\n - kanban\n")
monkeypatch.setenv("HERMES_HOME", str(home))
import tools.kanban_tools # ensure registered
from tools.registry import invalidate_check_fn_cache, registry
from toolsets import resolve_toolset
@ -120,6 +125,7 @@ def test_kanban_tools_visible_with_toolset_config(monkeypatch, tmp_path):
(home / "config.yaml").write_text("toolsets:\n - kanban\n")
monkeypatch.setenv("HERMES_HOME", str(home))
import tools.kanban_tools # ensure registered
from tools.registry import invalidate_check_fn_cache, registry
from toolsets import resolve_toolset