MCPcopy Index your code
hub / github.com/FSoft-AI4Code/CodeWiki / main

Function main

tests/smoke_test_mcp.py:40–222  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

38
39
40def main():
41 print("=== CodeWiki MCP Smoke Test (File-Side-Channel) ===\n")
42
43 store = SessionStore()
44 output_dir = tempfile.mkdtemp(prefix="codewiki_smoke_")
45
46 # -- 1. analyze_repo --
47 print("[1] analyze_repo")
48 result = json.loads(handle_analyze_repo({
49 "repo_path": REPO_PATH,
50 "output_dir": output_dir,
51 }, store))
52 check("returns session_id", "session_id" in result, str(result)[:200])
53 check("returns workspace_dir", "workspace_dir" in result, str(result.keys()))
54 check("returns stats", "stats" in result, str(result.keys()))
55 check("returns files", "files" in result, str(result.keys()))
56 check("stats has total_components",
57 "total_components" in result.get("stats", {}),
58 str(result.get("stats")))
59 check("stats has total_leaf_nodes",
60 "total_leaf_nodes" in result.get("stats", {}),
61 str(result.get("stats")))
62
63 session_id = result.get("session_id")
64 workspace_dir = result.get("workspace_dir")
65 check("session_id is non-empty", session_id and len(session_id) == 12, str(session_id))
66 check("workspace_dir exists on disk",
67 workspace_dir and Path(workspace_dir).is_dir(),
68 str(workspace_dir))
69
70 # -- 2. Workspace files verification --
71 print("\n[2] Workspace files verification")
72 ws = Path(workspace_dir)
73 check("component_index.json exists", (ws / "component_index.json").exists(), "")
74 check("leaf_nodes.json exists", (ws / "leaf_nodes.json").exists(), "")
75 check("languages.json exists", (ws / "languages.json").exists(), "")
76 check("summary.json exists", (ws / "summary.json").exists(), "")
77 check("sources/ directory exists", (ws / "sources").is_dir(), "")
78
79 # Read component_index.json and verify structure
80 comp_index = json.loads((ws / "component_index.json").read_text(encoding="utf-8"))
81 check("component_index is a list", isinstance(comp_index, list), type(comp_index).__name__)
82 check("component_index non-empty", len(comp_index) > 0, f"len={len(comp_index)}")
83 if comp_index:
84 first = comp_index[0]
85 check("component has id/type/file",
86 all(k in first for k in ("id", "type", "file")),
87 str(first.keys()))
88
89 # Read leaf_nodes.json
90 leaf_nodes = json.loads((ws / "leaf_nodes.json").read_text(encoding="utf-8"))
91 check("leaf_nodes is a list", isinstance(leaf_nodes, list), type(leaf_nodes).__name__)
92 total_leaf = result["stats"]["total_leaf_nodes"]
93 check("leaf_nodes matches stats count",
94 len(leaf_nodes) == total_leaf,
95 f"file={len(leaf_nodes)} vs stats={total_leaf}")
96
97 # -- 3. read_code_components (writes to workspace files) --

Callers 1

smoke_test_mcp.pyFile · 0.70

Calls 12

getMethod · 0.95
removeMethod · 0.95
createMethod · 0.95
SessionStoreClass · 0.90
handle_analyze_repoFunction · 0.90
checkFunction · 0.85
runMethod · 0.80
cleanupMethod · 0.80
startMethod · 0.45

Tested by

no test coverage detected