added cli

This commit is contained in:
2026-01-20 20:47:28 +05:30
parent 7c027834c0
commit 8b2d6a5046
13 changed files with 390 additions and 0 deletions

67
tests/cli/conftest.py Normal file
View File

@@ -0,0 +1,67 @@
from pathlib import Path
from typing import Callable
import pytest
from click.testing import CliRunner
@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"]