From 227aef3dbf9286789c481e67857ef6022a416462 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Fri, 21 Aug 2026 22:04:04 -0400 Subject: [PATCH] test: mocked-session rule tests stub the always-on exclusions lookup; tool count 24 (#2880) Co-Authored-By: Claude Fable 5 --- tests/test_mcp_tool_rulebooks.py | 2 +- tests/test_services_plugin_context.py | 9 +++++++++ tests/test_services_rulebooks.py | 9 +++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/tests/test_mcp_tool_rulebooks.py b/tests/test_mcp_tool_rulebooks.py index 199309e..526a2aa 100644 --- a/tests/test_mcp_tool_rulebooks.py +++ b/tests/test_mcp_tool_rulebooks.py @@ -169,7 +169,7 @@ def test_register_attaches_all_sixteen_tools(): mcp = FakeMCP() register(mcp) - assert len(mcp.names) == 22 + assert len(mcp.names) == 24 # +exclude/include_always_on_rulebook (milestone 297) # spot-check a few names assert "list_rulebooks" in mcp.names assert "create_rule" in mcp.names diff --git a/tests/test_services_plugin_context.py b/tests/test_services_plugin_context.py index f67aa0e..d0c9026 100644 --- a/tests/test_services_plugin_context.py +++ b/tests/test_services_plugin_context.py @@ -4,6 +4,15 @@ import pytest from tests.helpers import fake_note +@pytest.fixture(autouse=True) +def _no_exclusions(): + """build_session_context asks for the bound project's always-on + exclusions (milestone 297); these tests script the rules only.""" + with patch("scribe.services.plugin_context.rulebooks_svc.excluded_always_on_rulebooks", + AsyncMock(return_value=[])): + yield + + pytestmark = pytest.mark.usefixtures("_no_supersession") diff --git a/tests/test_services_rulebooks.py b/tests/test_services_rulebooks.py index c5871f6..2be99cb 100644 --- a/tests/test_services_rulebooks.py +++ b/tests/test_services_rulebooks.py @@ -8,6 +8,15 @@ import pytest from tests.helpers import fake_rule, fake_rulebook, fake_topic, make_mock_session +@pytest.fixture(autouse=True) +def _no_exclusions(): + """get_applicable_rules asks for the project's always-on exclusions + (milestone 297) through its own session; these mocked-session tests + script the rule queries only, so the exclusions lookup is stubbed empty.""" + with patch("scribe.services.rulebooks.excluded_always_on_rulebooks", AsyncMock(return_value=[])): + yield + + @pytest.mark.asyncio async def test_create_rulebook_stores_to_db(): mock_session = make_mock_session()