6Tests for documentation health check.
10Verify that check_docs_health correctly validates required documentation files.
14- Test all docs present.
15- Test individual missing files.
16- Test completely missing docs.
24 L4 — per-file presence checks
28- All four required files are checked.
29- Counts match actual file presence.
33from pathlib
import Path
39 """Test that all required docs are detected when present."""
40 (temp_project_root /
"docs" /
"ARCHITECTURE.md").write_text(
"# Arch", encoding=
"utf-8")
41 (temp_project_root /
"CHANGELOG.md").write_text(
"# Changelog", encoding=
"utf-8")
42 (temp_project_root /
"tests" /
"Tests_README.md").write_text(
"# Tests", encoding=
"utf-8")
43 (temp_project_root /
"tests" /
"run_tests.py").write_text(
"# runner", encoding=
"utf-8")
44 (temp_project_root /
"oc_diagnostics" /
"debug_config.json").write_text(
"{}", encoding=
"utf-8")
46 result = check_docs_health(temp_project_root)
49 assert result[
"total_required"] == 5
50 assert result[
"total_present"] == 5
54 """Test detection of missing ARCHITECTURE.md."""
55 (temp_project_root /
"CHANGELOG.md").write_text(
"# Changelog", encoding=
"utf-8")
56 (temp_project_root /
"tests" /
"Tests_README.md").write_text(
"# Tests", encoding=
"utf-8")
57 (temp_project_root /
"tests" /
"run_tests.py").write_text(
"# runner", encoding=
"utf-8")
58 (temp_project_root /
"oc_diagnostics" /
"debug_config.json").write_text(
"{}", encoding=
"utf-8")
60 result = check_docs_health(temp_project_root)
62 assert result[
"total_present"] == 4
63 arch_file = next(f
for f
in result[
"files"]
if f[
"name"] ==
"ARCHITECTURE.md")
64 assert arch_file[
"present"]
is False
68 """Test detection of missing debug_config.json."""
69 (temp_project_root /
"docs" /
"ARCHITECTURE.md").write_text(
"# Arch", encoding=
"utf-8")
70 (temp_project_root /
"CHANGELOG.md").write_text(
"# Changelog", encoding=
"utf-8")
71 (temp_project_root /
"tests" /
"Tests_README.md").write_text(
"# Tests", encoding=
"utf-8")
72 (temp_project_root /
"tests" /
"run_tests.py").write_text(
"# runner", encoding=
"utf-8")
74 result = check_docs_health(temp_project_root)
76 assert result[
"total_present"] == 4
77 config_file = next(f
for f
in result[
"files"]
if f[
"name"] ==
"debug_config.json")
78 assert config_file[
"present"]
is False
82 """CHANGELOG.md is required at Standard maturity (drift item B1)."""
83 (temp_project_root /
"docs" /
"ARCHITECTURE.md").write_text(
"# Arch", encoding=
"utf-8")
84 (temp_project_root /
"tests" /
"Tests_README.md").write_text(
"# Tests", encoding=
"utf-8")
85 (temp_project_root /
"tests" /
"run_tests.py").write_text(
"# runner", encoding=
"utf-8")
86 (temp_project_root /
"oc_diagnostics" /
"debug_config.json").write_text(
"{}", encoding=
"utf-8")
88 result = check_docs_health(temp_project_root)
90 assert result[
"total_present"] == 4
91 changelog_file = next(f
for f
in result[
"files"]
if f[
"name"] ==
"CHANGELOG.md")
92 assert changelog_file[
"present"]
is False
93 assert changelog_file[
"required"]
is True
97 """SECURITY.md is shown but not required outside Production maturity."""
98 result = check_docs_health(temp_project_root)
100 security_file = next(f
for f
in result[
"files"]
if f[
"name"] ==
"SECURITY.md")
101 assert security_file[
"present"]
is False
102 assert security_file[
"required"]
is False
104 assert result[
"total_required"] == 5
108 """SECURITY.md is required when production_mode=True (Appendix H Level 2)."""
109 result = check_docs_health(temp_project_root, production_mode=
True)
111 assert result[
"total_required"] == 6
112 security_file = next(f
for f
in result[
"files"]
if f[
"name"] ==
"SECURITY.md")
113 assert security_file[
"required"]
is True
117 """Test when no required docs exist."""
118 result = check_docs_health(temp_project_root)
120 assert result[
"total_required"] == 5
121 assert result[
"total_present"] == 0
125 """Test that file list has correct structure."""
126 result = check_docs_health(temp_project_root)
129 assert len(result[
"files"]) == 6
130 for file_info
in result[
"files"]:
131 assert "name" in file_info
132 assert "present" in file_info
133 assert "required" in file_info
test_docs_health_missing_architecture(Path temp_project_root)
test_docs_health_security_required_in_production(Path temp_project_root)
test_docs_health_all_present(Path temp_project_root)
test_docs_health_missing_config(Path temp_project_root)
test_docs_health_file_list_structure(Path temp_project_root)
test_docs_health_missing_changelog(Path temp_project_root)
test_docs_health_all_missing(Path temp_project_root)
test_docs_health_security_optional_outside_production(Path temp_project_root)