Files
doc-forge/tests/renderers/mcp/test_mcp_module_coverage.py
Vishesh 'ironeagle' Bangotra 5370a7faa2 feat(mcp): add MCP JSON renderer and CLI support, update tests accordingly
- Add MCPRenderer to generate MCP-native JSON bundles (index.json, nav.json, modules/*.json)
- Expose MCPRenderer via public API and CLI (`generate-mcp` command)
- Replace Markdown-based MCP output with structured JSON resources
- Update MCP renderer type stubs to match new JSON-based implementation
- Refactor MCP tests to validate JSON content, bundle structure, and navigation
- Fix MCP module coverage test to use explicit project_root for reliable discovery
2026-01-21 16:43:21 +05:30

35 lines
907 B
Python

from pathlib import Path
from docforge.loaders import GriffeLoader, discover_module_paths
from docforge import MCPRenderer
def test_mcp_emits_all_modules(tmp_path: Path) -> None:
project_root = Path(__file__).resolve().parents[3]
loader = GriffeLoader()
discovered_paths = discover_module_paths(
"docforge",
project_root=project_root,
)
project = loader.load_project(discovered_paths)
renderer = MCPRenderer()
renderer.generate_sources(project, tmp_path)
emitted = {
p.relative_to(tmp_path).as_posix()
for p in (tmp_path / "modules").rglob("*.json")
}
expected = {
f"modules/{m.path}.json"
for m in project.get_all_modules()
}
missing = expected - emitted
assert not missing, f"Missing MCP module JSON files: {missing}"
# also assert nav.json exists
assert (tmp_path / "nav.json").exists()