Files
doc-forge/tests/nav/test_resolver.py
Vishesh 'ironeagle' Bangotra 06ffd2febd chore(release): 0.0.7
Squash-merge lib-standardisation: adopt repo standards across packaging,
tooling, docs, and CI.

- standardize pyproject.toml (canonical packaging, lint config, extras, GSDFC pydoclint)
- add py.typed marker, modernize type hints and Google-style docstrings
- nest generated docs under docs/lib and docs/mcp; add hand-written wiki
- adopt standard Type A PyPI CI pipeline (tag==version guard + quality gate)
- promote generated CHANGELOG.md; bump version to 0.0.7
2026-10-17 02:16:44 +05:30

104 lines
2.1 KiB
Python

from pathlib import Path
import pytest
from docforge.nav import NavSpec, resolve_nav
def _write_docs(root: Path, paths: list[str]) -> None:
for p in paths:
full = root / p
full.parent.mkdir(parents=True, exist_ok=True)
full.write_text(f"# {p}", encoding="utf-8")
def test_resolve_simple_nav(tmp_path: Path):
docs = tmp_path / "docs"
_write_docs(
docs,
[
"openapi_first/index.md",
"openapi_first/app.md",
"openapi_first/client.md",
],
)
spec = NavSpec(
home="openapi_first/index.md",
groups={
"Core": [
"openapi_first/app.md",
"openapi_first/client.md",
]
},
)
resolved = resolve_nav(spec, docs)
assert resolved.home == "openapi_first/index.md"
assert list(resolved.groups["Core"]) == [
docs / "openapi_first/app.md",
docs / "openapi_first/client.md",
]
def test_wildcard_expansion_preserves_order(tmp_path: Path):
docs = tmp_path / "docs"
_write_docs(
docs,
[
"pkg/a.md",
"pkg/b.md",
"pkg/c.md",
],
)
spec = NavSpec(
home=None,
groups={"All": ["pkg/*.md"]},
)
resolved = resolve_nav(spec, docs)
paths = [p.name for p in resolved.groups["All"]]
assert paths == ["a.md", "b.md", "c.md"]
def test_missing_doc_file_raises(tmp_path: Path):
docs = tmp_path / "docs"
docs.mkdir()
spec = NavSpec(
home="missing.md",
groups={},
)
with pytest.raises(FileNotFoundError):
resolve_nav(spec, docs)
def test_all_files_returns_flat_sequence(tmp_path: Path):
docs = tmp_path / "docs"
_write_docs(
docs,
[
"a.md",
"b.md",
"c.md",
],
)
spec = NavSpec(
home="a.md",
groups={"G": ["b.md", "c.md"]},
)
resolved = resolve_nav(spec, docs)
files = list(resolved.all_files())
assert files == [
docs / "a.md",
docs / "b.md",
docs / "c.md",
]