UXInteract / task_036 /tests /validate_enhanced.py
DojiSum's picture
Publish the current 141-task UXInteract release
ef987bb verified
Raw History Blame Contribute Delete
1.34 kB
"""Mutation checks: new pairs, incomplete samples, changed captions, stale shard cleanup."""
from pathlib import Path
import shutil
import tempfile
from validate_outputs import check_workspace, expected
ROOT = Path.cwd()
with tempfile.TemporaryDirectory(prefix="task052-mutation-") as tmp:
workspace = Path(tmp)
shutil.copytree(ROOT, workspace, dirs_exist_ok=True, ignore=shutil.ignore_patterns('tests', 'logs', 'shards', '__pycache__', 'node_modules'))
dataset = workspace / "data" / "dataset"
shutil.copy2(dataset / "000001.jpg", dataset / "000777.jpg")
(dataset / "000777.txt").write_text("a newly added complete sample\n", encoding="utf-8")
shutil.copy2(dataset / "000002.jpg", dataset / "000888.jpg")
(dataset / "000889.txt").write_text("no matching image\n", encoding="utf-8")
(dataset / "000003.txt").write_text("changed caption during verifier\n", encoding="utf-8")
shard_dir = workspace / "shards"
shard_dir.mkdir()
(shard_dir / "dataset-999999.tar").write_bytes(b"stale")
pairs, total = expected(workspace)
assert "000777" in pairs and "000888" not in pairs and "000889" not in pairs
check_workspace(workspace)
assert total >= len(pairs) + 2
assert not (shard_dir / "dataset-999999.tar").exists(), "old shard was not cleaned"
print("mutation cases passed")