This commit is contained in:
eddiesoehnel committed 2026-07-24 16:17:28 -06:00
1 parent 1e52a733d1
commit bd8f9a641f
27 files changed
+817 -33

No files matched your search

+2 -1
View File
@@ -8,4 +8,5 @@ python -m unittest discover -s tests -p "test_*.py"
The tests validate the current repository and protect key failure cases in
`scripts/validate_repository.py`, including mismatches between
`repository-variables.json` and `repository.json`.
`repository-variables.json` and `repository.json`, duplicate content IDs, and
missing files declared by `content-index.json`.
+36
View File
@@ -47,6 +47,42 @@ class RepositoryValidationTests(unittest.TestCase):
)
)
def test_duplicate_content_id_fails(self) -> None:
with tempfile.TemporaryDirectory() as directory:
copy = Path(directory) / "repository"
shutil.copytree(ROOT, copy, ignore=shutil.ignore_patterns(".git", "__pycache__"))
index_path = copy / "content-index.json"
index = json.loads(index_path.read_text(encoding="utf-8"))
duplicate = dict(index["items"][0])
duplicate["path"] = "docs/README.md"
index["items"].append(duplicate)
index_path.write_text(json.dumps(index, indent=2) + "\n", encoding="utf-8")
result = VALIDATOR.validate(copy)
self.assertFalse(result["passed"])
self.assertTrue(
any(
"Duplicate content_id in content-index.json" in item["message"]
for item in result["findings"]
)
)
def test_missing_indexed_content_fails(self) -> None:
with tempfile.TemporaryDirectory() as directory:
copy = Path(directory) / "repository"
shutil.copytree(ROOT, copy, ignore=shutil.ignore_patterns(".git", "__pycache__"))
index_path = copy / "content-index.json"
index = json.loads(index_path.read_text(encoding="utf-8"))
index["items"][0]["path"] = "docs/missing-document.md"
index_path.write_text(json.dumps(index, indent=2) + "\n", encoding="utf-8")
result = VALIDATOR.validate(copy)
self.assertFalse(result["passed"])
self.assertTrue(
any(
"Indexed content path does not exist" in item["message"]
for item in result["findings"]
)
)
if __name__ == "__main__":
unittest.main()