52 lines
1.5 KiB
Python
52 lines
1.5 KiB
Python
from __future__ import annotations
|
|||
|
|
|
||
|
|
import sys
|
||
|
|
import unittest
|
||
|
|
from pathlib import Path
|
||
|
|
|
||
|
|
|
||
|
|
ROOT = Path(__file__).resolve().parents[1]
|
||
|
|
sys.path.insert(0, str(ROOT / "scripts"))
|
||
|
|
|
||
|
|
from check_harness import ( # noqa: E402
|
||
|
|
CORE_DOCUMENT_REQUIREMENTS,
|
||
|
|
CORE_PAGE_PATHS,
|
||
|
|
REQUIRED_FILES,
|
||
|
|
check_core_documents,
|
||
|
|
check_task_template,
|
||
|
|
missing_sections,
|
||
|
|
)
|
||
|
|
from wiki_docs import load_config # noqa: E402
|
||
|
|
|
||
|
|
|
||
|
|
class CoreDocumentTests(unittest.TestCase):
|
||
|
|
def test_current_core_documents_have_required_sections(self) -> None:
|
||
|
|
errors: list[str] = []
|
||
|
|
check_core_documents(errors)
|
||
|
|
self.assertEqual(errors, [])
|
||
|
|
|
||
|
|
def test_missing_sections_reports_each_heading(self) -> None:
|
||
|
|
missing = missing_sections("# 页面\n## 已有\n", ("## 已有", "## 缺少"))
|
||
|
|
self.assertEqual(missing, ["## 缺少"])
|
||
|
|
|
||
|
|
def test_every_core_document_is_required(self) -> None:
|
||
|
|
for path in CORE_DOCUMENT_REQUIREMENTS:
|
||
|
|
self.assertIn(path, REQUIRED_FILES)
|
||
|
|
|
||
|
|
def test_every_core_page_has_exact_mapping(self) -> None:
|
||
|
|
config = load_config()
|
||
|
|
mappings = {mapping.page: mapping.path for mapping in config.mappings}
|
||
|
|
for page, path in CORE_PAGE_PATHS.items():
|
||
|
|
self.assertEqual(mappings.get(page), path)
|
||
|
|
|
||
|
|
|
||
|
|
class TaskTemplateTests(unittest.TestCase):
|
||
|
|
def test_task_template_requires_document_impact(self) -> None:
|
||
|
|
errors: list[str] = []
|
||
|
|
check_task_template(errors)
|
||
|
|
self.assertEqual(errors, [])
|
||
|
|
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
unittest.main()
|