When guards allow, the tool executes normally.
(self)
| 276 | |
| 277 | @pytest.mark.asyncio |
| 278 | async def test_guard_allows_tool(self): |
| 279 | """When guards allow, the tool executes normally.""" |
| 280 | tm = FakeToolManager(result="success") |
| 281 | backend = McpToolBackend(tm, enable_guards=True) |
| 282 | |
| 283 | with ( |
| 284 | patch( |
| 285 | "mcp_cli.planning.backends._check_guards", |
| 286 | return_value=None, |
| 287 | ), |
| 288 | patch( |
| 289 | "mcp_cli.planning.backends._record_result", |
| 290 | ) as mock_record, |
| 291 | ): |
| 292 | request = ToolExecutionRequest( |
| 293 | tool_name="read_file", |
| 294 | args={"path": "/tmp/x"}, |
| 295 | step_id="step-7", |
| 296 | ) |
| 297 | result = await backend.execute_tool(request) |
| 298 | |
| 299 | assert result.success |
| 300 | assert result.result == "success" |
| 301 | assert len(tm.calls) == 1 |
| 302 | # Result was recorded |
| 303 | mock_record.assert_called_once_with("read_file", {"path": "/tmp/x"}, "success") |
| 304 | |
| 305 | @pytest.mark.asyncio |
| 306 | async def test_guards_disabled(self): |
nothing calls this directly
no test coverage detected