MCPcopy Create free account
hub / github.com/IBM/mcp-cli / test_guard_allows_tool

Method test_guard_allows_tool

tests/planning/test_backends.py:278–303  ·  view source on GitHub ↗

When guards allow, the tool executes normally.

(self)

Source from the content-addressed store, hash-verified

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):

Callers

nothing calls this directly

Calls 3

execute_toolMethod · 0.95
McpToolBackendClass · 0.90
FakeToolManagerClass · 0.70

Tested by

no test coverage detected