-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest_docs_audit.py
More file actions
65 lines (53 loc) · 1.78 KB
/
test_docs_audit.py
File metadata and controls
65 lines (53 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
"""Tests for doc/development/docs_audit.py helpers."""
from __future__ import annotations
import importlib.util
from pathlib import Path
import pytest
REPO_ROOT = Path(__file__).resolve().parents[2]
def _load_docs_audit():
path = REPO_ROOT / "doc" / "development" / "docs_audit.py"
spec = importlib.util.spec_from_file_location("docs_audit", path)
assert spec and spec.loader
mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(mod)
return mod
@pytest.fixture()
def format_strict_issue_detail():
return _load_docs_audit().format_strict_issue_detail
def test_format_strict_issue_detail_lists_link_issues(
format_strict_issue_detail,
) -> None:
detail = format_strict_issue_detail(
link_issues=[(Path("doc/x.md"), 10, "missing.md", "missing: doc/missing.md")],
anchor_issues=[],
anchor_checked=False,
spec_issues=[],
coverage=[],
doc_missing_agents=[],
doc_missing_readme=[],
agents_no_readme=[],
readme_no_agents=[],
doc_agents_structure=[],
)
assert "Broken relative links" in detail
assert "doc/x.md:10" in detail
assert "`missing.md`" in detail
def test_format_strict_issue_detail_anchor_section_when_checked(
format_strict_issue_detail,
) -> None:
detail = format_strict_issue_detail(
link_issues=[],
anchor_issues=[
(Path("doc/a.md"), 2, "b.md#frag", "anchor #frag not found (headings in `doc/b.md`)")
],
anchor_checked=True,
spec_issues=[],
coverage=[],
doc_missing_agents=[],
doc_missing_readme=[],
agents_no_readme=[],
readme_no_agents=[],
doc_agents_structure=[],
)
assert "Bad markdown anchors" in detail
assert "doc/a.md:2" in detail