added
This commit is contained in:
1 parent
19ee35b3b5
commit
2772a0b8d6
21 files changed
+907
-14
No files matched your search
@@ -0,0 +1,11 @@
|
||||
# Tests
|
||||
|
||||
Run the read-only repository compatibility checks:
|
||||
|
||||
```text
|
||||
python -B -m unittest discover -s tests -p "test_*.py"
|
||||
```
|
||||
|
||||
The tests validate JSON parsing, version alignment, release-manifest paths,
|
||||
repository entrypoints, skill frontmatter, synthetic examples, and ownership
|
||||
invariants. They do not access personal sources or remote discovery services.
|
||||
@@ -0,0 +1,94 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import re
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
class RepositoryTests(unittest.TestCase):
|
||||
def test_json_files_parse(self) -> None:
|
||||
for name in ("repository.json", "repository-variables.json", "pid-release.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()
|
||||
repository = json.loads((ROOT / "repository.json").read_text(encoding="utf-8"))
|
||||
release = json.loads((ROOT / "pid-release.json").read_text(encoding="utf-8"))
|
||||
citation = (ROOT / "CITATION.cff").read_text(encoding="utf-8")
|
||||
changelog = (ROOT / "CHANGELOG.md").read_text(encoding="utf-8")
|
||||
self.assertEqual("0.2.5", version)
|
||||
self.assertEqual(version, repository["version"])
|
||||
self.assertEqual(version, release["repo_version"])
|
||||
self.assertIn(f"version: {version}", citation)
|
||||
self.assertIn(f"## [{version}]", changelog)
|
||||
|
||||
def test_release_manifest_paths_exist(self) -> None:
|
||||
release = json.loads((ROOT / "pid-release.json").read_text(encoding="utf-8"))
|
||||
tracked_names = {
|
||||
path.relative_to(ROOT).as_posix().lower()
|
||||
for path in ROOT.rglob("*")
|
||||
if path.is_file() and ".git" not in path.parts
|
||||
}
|
||||
for item in release["files"]:
|
||||
with self.subTest(path=item["path"]):
|
||||
self.assertIn(item["path"].lower(), tracked_names)
|
||||
|
||||
def test_declared_repository_paths_exist(self) -> None:
|
||||
repository = json.loads((ROOT / "repository.json").read_text(encoding="utf-8"))
|
||||
paths = [
|
||||
repository["entrypoints"]["human"],
|
||||
repository["entrypoints"]["ai"],
|
||||
*[
|
||||
value
|
||||
for key, value in repository["entrypoints"].items()
|
||||
if key not in {"human", "ai"} and value
|
||||
],
|
||||
*[item["path"] for item in repository["contents"]],
|
||||
]
|
||||
for path in paths:
|
||||
with self.subTest(path=path):
|
||||
self.assertTrue((ROOT / path).exists())
|
||||
|
||||
def test_maintainer_skills_have_frontmatter(self) -> None:
|
||||
skill_paths = [
|
||||
"skills/PID-initial-creation-skill.md",
|
||||
"skills/PID-update-maintenance-skill.md",
|
||||
"skills/PID-version-checker-skill.md",
|
||||
"skills/PID-release-compatibility-checker-skill.md",
|
||||
]
|
||||
for relative in skill_paths:
|
||||
text = (ROOT / relative).read_text(encoding="utf-8-sig")
|
||||
with self.subTest(path=relative):
|
||||
self.assertTrue(text.startswith("---\n"))
|
||||
self.assertRegex(text, r"(?m)^name:\s*\S+")
|
||||
self.assertRegex(text, r"(?m)^description:\s*.+")
|
||||
|
||||
def test_user_owned_variables_remain_declared(self) -> None:
|
||||
release = json.loads((ROOT / "pid-release.json").read_text(encoding="utf-8"))
|
||||
user_paths = {
|
||||
item["path"]
|
||||
for item in release["files"]
|
||||
if item.get("owner") == "user"
|
||||
}
|
||||
self.assertIn(
|
||||
"skills/PID-update-maintenance-skill-user-variables.md", user_paths
|
||||
)
|
||||
self.assertIn("review-drafts/**", release["user_owned_patterns"])
|
||||
self.assertIn("skills-receipts/**", release["user_owned_patterns"])
|
||||
|
||||
def test_examples_are_synthetic(self) -> None:
|
||||
for path in (ROOT / "examples").glob("*.md"):
|
||||
if path.name == "README.md":
|
||||
continue
|
||||
with self.subTest(path=path.name):
|
||||
text = path.read_text(encoding="utf-8")
|
||||
self.assertRegex(text.lower(), r"synthetic")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user