added mcp server code
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
from pathlib import Path
|
||||
from typing import Callable
|
||||
|
||||
import json
|
||||
import pytest
|
||||
from pathlib import Path
|
||||
|
||||
from click.testing import CliRunner
|
||||
|
||||
|
||||
@@ -65,3 +65,47 @@ def mock_mkdocs_serve(monkeypatch):
|
||||
fake_serve,
|
||||
)
|
||||
return lambda: called["value"]
|
||||
|
||||
@pytest.fixture
|
||||
def fake_mcp_docs(tmp_path: Path) -> Path:
|
||||
"""
|
||||
Create a minimal valid MCP bundle in mcp_docs/.
|
||||
"""
|
||||
mcp_root = tmp_path / "mcp_docs"
|
||||
modules_dir = mcp_root / "modules"
|
||||
modules_dir.mkdir(parents=True)
|
||||
|
||||
(mcp_root / "index.json").write_text(
|
||||
json.dumps({"project": "test", "type": "docforge-model"}),
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
(mcp_root / "nav.json").write_text(
|
||||
json.dumps([]),
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
(modules_dir / "test.mod.json").write_text(
|
||||
json.dumps({"module": "test.mod", "content": {}}),
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
return mcp_root
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_mcp_server_run(monkeypatch):
|
||||
"""
|
||||
Mock MCPServer.run so no real server is started.
|
||||
"""
|
||||
called = {"value": False}
|
||||
|
||||
def fake_run(self, transport="streamable-http"):
|
||||
called["value"] = True
|
||||
|
||||
monkeypatch.setattr(
|
||||
"docforge.servers.MCPServer.run",
|
||||
fake_run,
|
||||
)
|
||||
|
||||
return lambda: called["value"]
|
||||
|
||||
Reference in New Issue
Block a user