When guards block, the tool is not executed.
(self)
| 252 | |
| 253 | @pytest.mark.asyncio |
| 254 | async def test_guard_blocks_tool(self): |
| 255 | """When guards block, the tool is not executed.""" |
| 256 | tm = FakeToolManager(result="should not see this") |
| 257 | backend = McpToolBackend(tm, enable_guards=True) |
| 258 | |
| 259 | # Mock _check_guards to return a block |
| 260 | with patch( |
| 261 | "mcp_cli.planning.backends._check_guards", |
| 262 | return_value="Budget exhausted", |
| 263 | ): |
| 264 | request = ToolExecutionRequest( |
| 265 | tool_name="write_file", |
| 266 | args={"path": "/tmp/x", "content": "data"}, |
| 267 | step_id="step-6", |
| 268 | ) |
| 269 | result = await backend.execute_tool(request) |
| 270 | |
| 271 | assert not result.success |
| 272 | assert "Guard blocked" in result.error |
| 273 | assert "Budget exhausted" in result.error |
| 274 | # Tool was never called |
| 275 | assert len(tm.calls) == 0 |
| 276 | |
| 277 | @pytest.mark.asyncio |
| 278 | async def test_guard_allows_tool(self): |
nothing calls this directly
no test coverage detected