added
This commit is contained in:
1 parent
1e52a733d1
commit
bd8f9a641f
27 files changed
+817
-33
No files matched your search
@@ -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()
|
||||
Reference in new issue
Block a user