MCPcopy Create free account
hub / github.com/ScaleML/AgentSPEX / test_filesystem_roundtrip

Function test_filesystem_roundtrip

tests/tool_tests/test_file.py:12–54  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

10@pytest.mark.asyncio
11@pytest.mark.mcp
12async def test_filesystem_roundtrip():
13 async with Client(MCP_URL) as client:
14
15 async def call_tool(tool_name: str, **kwargs) -> Dict[str, Any]:
16 res = await client.call_tool(tool_name, kwargs or {})
17 return getattr(res, "data", None) or {}
18
19 mk = await call_tool("fs_mkdir", path="testdir")
20 assert "error" not in mk, f"fs_mkdir testdir failed: {mk}"
21 base = mk.get("path", "testdir")
22
23 w = await call_tool(
24 "fs_write", path=f"{base}/hello.txt", content="hello world", mode="text"
25 )
26 assert "error" not in w, f"fs_write failed: {w}"
27 vpath = w["path"]
28
29 ls = await call_tool("fs_list", path=base)
30 assert "error" not in ls, f"fs_list failed: {ls}"
31 assert any(
32 e["name"] == "hello.txt" for e in ls.get("entries", [])
33 ), f"fs_list missing hello.txt: {ls}"
34
35 mk2 = await call_tool("fs_mkdir", path="testdir2")
36 assert "error" not in mk2, f"fs_mkdir testdir2 failed: {mk2}"
37
38 mv = await call_tool(
39 "fs_move", src=vpath, dst="testdir2/goodbye.txt", overwrite=True
40 )
41 assert "error" not in mv, f"fs_move failed: {mv}"
42 moved = mv["dst"]
43
44 rd = await call_tool("fs_read", path=moved)
45 assert "error" not in rd, f"fs_read failed: {rd}"
46 assert rd.get("text") == "hello world", f"fs_read mismatch: {rd}"
47
48 for target, kw in [
49 (moved, {}),
50 ("testdir2", {"recursive": True}),
51 ("testdir", {"recursive": True}),
52 ]:
53 rm = await call_tool("fs_remove", path=target, **kw)
54 assert "error" not in rm, f"fs_remove {target} failed: {rm}"

Callers

nothing calls this directly

Calls 2

getMethod · 0.80
call_toolFunction · 0.70

Tested by

no test coverage detected