|
3 | 3 | from __future__ import annotations |
4 | 4 |
|
5 | 5 | import subprocess |
| 6 | +import json |
| 7 | +import shutil |
6 | 8 | import sys |
7 | 9 | import tempfile |
8 | 10 | from pathlib import Path |
@@ -167,7 +169,40 @@ def assert_direct_validator_invariants() -> None: |
167 | 169 | ) |
168 | 170 |
|
169 | 171 |
|
| 172 | +def assert_minimal_routine_deposit() -> None: |
| 173 | + """Validate the shipped specimen at its real destination paths, without repair.""" |
| 174 | + example = ROOT / "examples" / "minimal_routine_deposit" |
| 175 | + with tempfile.TemporaryDirectory() as temporary: |
| 176 | + workspace = Path(temporary) / "workspace" |
| 177 | + shutil.copytree(ROOT, workspace, ignore=shutil.ignore_patterns(".git", "__pycache__")) |
| 178 | + for filename, kind, id_key, artifact, path_key in ( |
| 179 | + ("packet_record.json", "packets", "packet_id", "datadrop_packet.md", "path"), |
| 180 | + ("visit_record.json", "visits", "visit_id", "signoff.md", "signoff_path"), |
| 181 | + ): |
| 182 | + record = json.loads((example / filename).read_text(encoding="utf-8")) |
| 183 | + destination = workspace / "registry" / kind / record[id_key][:4] |
| 184 | + destination.mkdir(parents=True, exist_ok=True) |
| 185 | + shutil.copy2(example / filename, destination / (record[id_key] + ".json")) |
| 186 | + artifact_path = workspace / record[path_key] |
| 187 | + artifact_path.parent.mkdir(parents=True, exist_ok=True) |
| 188 | + shutil.copy2(example / artifact, artifact_path) |
| 189 | + for args in ( |
| 190 | + ("scripts/generate_registry_views.py",), |
| 191 | + ("scripts/validate_repo.py", "--registry"), |
| 192 | + ("scripts/generate_registry_views.py", "--check"), |
| 193 | + ): |
| 194 | + result = subprocess.run( |
| 195 | + [sys.executable, *args], cwd=workspace, text=True, |
| 196 | + capture_output=True, check=False, |
| 197 | + ) |
| 198 | + if result.returncode: |
| 199 | + raise AssertionError( |
| 200 | + f"minimal routine deposit failed: {args}\n{result.stdout}\n{result.stderr}" |
| 201 | + ) |
| 202 | + |
| 203 | + |
170 | 204 | def main() -> int: |
| 205 | + assert_minimal_routine_deposit() |
171 | 206 | assert_direct_validator_invariants() |
172 | 207 | assert_valid( |
173 | 208 | "valid schema fixtures", "--fixtures", "--check-references", "--check-tags" |
|
0 commit comments