cli-cleanup (#1)
Reviewed-on: #1 Co-authored-by: Vishesh 'ironeagle' Bangotra <aetoskia@gmail.com> Co-committed-by: Vishesh 'ironeagle' Bangotra <aetoskia@gmail.com>
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import sys
|
||||
import json
|
||||
import pytest
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from click.testing import CliRunner
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@@ -16,3 +18,109 @@ def temp_package(tmp_path: Path):
|
||||
sys.path.insert(0, str(tmp_path))
|
||||
yield pkg
|
||||
sys.path.remove(str(tmp_path))
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def cli_runner() -> CliRunner:
|
||||
"""Click CLI runner."""
|
||||
return CliRunner()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def fake_mkdocs_yml(tmp_path: Path) -> Path:
|
||||
"""Create a minimal mkdocs.yml file."""
|
||||
yml = tmp_path / "mkdocs.yml"
|
||||
yml.write_text(
|
||||
"""
|
||||
site_name: Test Docs
|
||||
nav: []
|
||||
plugins:
|
||||
- mkdocstrings
|
||||
""",
|
||||
encoding="utf-8",
|
||||
)
|
||||
return yml
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_mkdocs_load_config(monkeypatch):
|
||||
"""Mock mkdocs.config.load_config."""
|
||||
def fake_load_config(path):
|
||||
return object() # dummy config object
|
||||
|
||||
monkeypatch.setattr(
|
||||
"mkdocs.config.load_config",
|
||||
fake_load_config,
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_mkdocs_build(monkeypatch):
|
||||
called = {"value": False}
|
||||
|
||||
def fake_build(config):
|
||||
called["value"] = True
|
||||
|
||||
monkeypatch.setattr(
|
||||
"mkdocs.commands.build.build",
|
||||
fake_build,
|
||||
)
|
||||
return lambda: called["value"]
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_mkdocs_serve(monkeypatch):
|
||||
called = {"value": False}
|
||||
|
||||
def fake_serve(*args, **kwargs):
|
||||
called["value"] = True
|
||||
|
||||
monkeypatch.setattr(
|
||||
"mkdocs.commands.serve.serve",
|
||||
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