62 lines
2.2 KiB
Python
62 lines
2.2 KiB
Python
#!/usr/bin/env python3
|
|
"""Tests for preparing first external oracle capture packets."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
|
|
|
|
def test_prepare_oracle_capture_packets_writes_packets_manifest_and_next_steps(tmp_path: Path) -> None:
|
|
completed = subprocess.run(
|
|
[
|
|
sys.executable,
|
|
"scripts/prepare_oracle_capture_packets.py",
|
|
"--oracle-file",
|
|
"references/oracle/dasha_shadbala_oracle_cases.json",
|
|
"--output-dir",
|
|
str(tmp_path),
|
|
],
|
|
cwd=ROOT,
|
|
text=True,
|
|
capture_output=True,
|
|
timeout=30,
|
|
check=False,
|
|
)
|
|
|
|
assert completed.returncode == 0, completed.stderr or completed.stdout
|
|
report = json.loads(completed.stdout)
|
|
assert report["scope"] == "external_oracle_capture_packet_preparation"
|
|
assert report["packet_count"] == 5
|
|
assert report["validator_summary"]["valid_packets"] == 0
|
|
assert report["validator_summary"]["ready_for_calibration"] == 0
|
|
assert report["first_priority_packet"].endswith("external_template_steve_jobs_dasha_lahiri.json")
|
|
|
|
packet = tmp_path / "external_template_steve_jobs_dasha_lahiri.json"
|
|
manifest = tmp_path / "capture_manifest.json"
|
|
next_steps = tmp_path / "OPERATOR_NEXT_STEPS.md"
|
|
assert packet.exists()
|
|
assert manifest.exists()
|
|
assert next_steps.exists()
|
|
|
|
packet_data = json.loads(packet.read_text(encoding="utf-8"))
|
|
assert packet_data["status"] == "draft"
|
|
assert packet_data["metadata"]["source_artifact"] == "references/oracle/artifacts/"
|
|
assert packet_data["target_placeholders"]["target.vimshottari_start_date"] is None
|
|
|
|
manifest_data = json.loads(manifest.read_text(encoding="utf-8"))
|
|
assert manifest_data["scope"] == "external_oracle_capture_packet_manifest"
|
|
assert manifest_data["packet_count"] == 5
|
|
assert packet.name in manifest_data["packets"]
|
|
|
|
guide = next_steps.read_text(encoding="utf-8")
|
|
assert "external_template_steve_jobs_dasha_lahiri.json" in guide
|
|
assert "oracle_evidence_validator.py" in guide
|
|
assert "--apply-packet" in guide
|
|
assert "不得把本仓库本地输出当作 external oracle" in guide
|