This commit is contained in:
eddiesoehnel committed 2026-07-25 13:12:23 -06:00
1 parent ca73bd5690
commit e1d8deb861
23 files changed
+1238 -6

No files matched your search

+11
View File
@@ -0,0 +1,11 @@
# Tests
Run the repository metadata and structural tests from the repository root:
```text
python -m unittest discover -s tests -p "test_*.py"
```
These tests are read-only. They validate repository metadata, versions,
declared paths, content-index integrity, source documents, and Python syntax.
They do not run the mutating Hugo publication pipeline.
+63
View File
@@ -0,0 +1,63 @@
from __future__ import annotations
import ast
import json
import unittest
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
class RepositoryTests(unittest.TestCase):
def test_machine_readable_files_parse(self) -> None:
for name in ("repository.json", "repository-variables.json", "content-index.json"):
with self.subTest(name=name):
json.loads((ROOT / name).read_text(encoding="utf-8"))
def test_versions_align(self) -> None:
version = (ROOT / "VERSION").read_text(encoding="utf-8").strip()
manifest = json.loads((ROOT / "repository.json").read_text(encoding="utf-8"))
citation = (ROOT / "CITATION.cff").read_text(encoding="utf-8")
self.assertEqual(version, manifest["version"])
self.assertIn(f"version: {version}", citation)
def test_declared_paths_exist(self) -> None:
manifest = json.loads((ROOT / "repository.json").read_text(encoding="utf-8"))
paths = [
manifest["entrypoints"]["human"],
manifest["entrypoints"]["ai"],
*[
value
for key, value in manifest["entrypoints"].items()
if key not in {"human", "ai"} and value
],
*[item["path"] for item in manifest["contents"]],
]
for path in paths:
with self.subTest(path=path):
self.assertTrue((ROOT / path).exists())
def test_content_index_integrity(self) -> None:
index = json.loads((ROOT / "content-index.json").read_text(encoding="utf-8"))
ids = [item["content_id"] for item in index["items"]]
paths = [item["path"] for item in index["items"]]
self.assertEqual(13, len(index["items"]))
self.assertEqual(len(ids), len(set(ids)))
self.assertEqual(len(paths), len(set(paths)))
for path in paths:
with self.subTest(path=path):
self.assertTrue((ROOT / path).is_file())
def test_python_syntax(self) -> None:
python_files = sorted((ROOT / "api").rglob("*.py")) + sorted(
(ROOT / "skills-scripts").rglob("*.py")
)
self.assertTrue(python_files)
for path in python_files:
with self.subTest(path=path.relative_to(ROOT).as_posix()):
ast.parse(path.read_text(encoding="utf-8-sig"), filename=str(path))
if __name__ == "__main__":
unittest.main()