100 lines
3.5 KiB
Python
100 lines
3.5 KiB
Python
from __future__ import annotations
|
|
|
|
import hashlib
|
|
import json
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
from pathlib import Path
|
|
|
|
from scripts.three_engine_parity_replay_validator import validate_manifest
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
|
|
|
|
def test_three_engine_parity_manifest_exposes_raw_coverage_and_formula_mismatches() -> None:
|
|
result = validate_manifest(ROOT / "references/oracle/three_engine_parity_replay_manifest.json")
|
|
|
|
assert result["status"] == "mismatch"
|
|
assert result["comparison_row_count"] == 92
|
|
assert result["match_count"] == 32
|
|
assert result["mismatch_count"] == 60
|
|
assert result["tested"] is True
|
|
assert result["blocked_reason"] is None
|
|
assert result["missing_high_rigor_sections"] == []
|
|
|
|
|
|
def test_three_engine_parity_validator_accepts_one_same_chart_row(tmp_path: Path) -> None:
|
|
raw = tmp_path / "vedastro.json"
|
|
raw.write_text('{"source":"official"}', encoding="utf-8")
|
|
manifest = {
|
|
"case_id": "public_same_chart_001",
|
|
"birth_data_policy": "public_case_only",
|
|
"status": "tested",
|
|
"engines": {
|
|
"VedAstro": {
|
|
"status": "official_verified",
|
|
"official_raw_response_path": "vedastro.json",
|
|
"artifact_hash": hashlib.sha256(raw.read_bytes()).hexdigest(),
|
|
"settings": {"ayanamsa": "lahiri"},
|
|
},
|
|
"PyJHora_JHora": {"status": "tested", "raw_output_path": "references/oracle/artifacts/pyjhora.txt"},
|
|
"jyotishganit": {"status": "tested", "raw_output_path": "references/oracle/artifacts/jyotishganit.json"},
|
|
},
|
|
"comparison_rows": [
|
|
{
|
|
"section": "D1",
|
|
"field": "Sun.longitude",
|
|
"local_value": 27.1,
|
|
"oracle_values": {"VedAstro": 27.1, "PyJHora_JHora": 27.1, "jyotishganit": 27.1},
|
|
"status": "match",
|
|
}
|
|
],
|
|
}
|
|
path = tmp_path / "three_engine_parity_replay_manifest.json"
|
|
path.write_text(json.dumps(manifest), encoding="utf-8")
|
|
|
|
result = validate_manifest(path)
|
|
|
|
assert result["status"] == "partial"
|
|
assert result["blocked_reason"] == "missing_high_rigor_sections"
|
|
assert result["tested"] is True
|
|
assert result["comparison_row_count"] == 1
|
|
assert result["match_count"] == 1
|
|
|
|
|
|
def test_validator_require_pass_rejects_blocked_manifest(tmp_path: Path) -> None:
|
|
root = Path(__file__).resolve().parents[1]
|
|
manifest = tmp_path / "blocked_manifest.json"
|
|
manifest.write_text(
|
|
json.dumps(
|
|
{
|
|
"case_id": "blocked_case",
|
|
"birth_data_policy": "public_case_only",
|
|
"engines": {
|
|
"VedAstro": {"status": "blocked"},
|
|
"PyJHora_JHora": {"status": "blocked"},
|
|
"jyotishganit": {"status": "blocked"},
|
|
},
|
|
"comparison_rows": [
|
|
{
|
|
"section": "D1",
|
|
"field": "Sun.longitude",
|
|
"local_value": 1.0,
|
|
"oracle_values": {},
|
|
"status": "blocked",
|
|
}
|
|
],
|
|
}
|
|
),
|
|
encoding="utf-8",
|
|
)
|
|
completed = subprocess.run(
|
|
[sys.executable, "scripts/three_engine_parity_replay_validator.py", str(manifest), "--require-pass"],
|
|
cwd=root,
|
|
capture_output=True,
|
|
text=True,
|
|
check=False,
|
|
)
|
|
assert completed.returncode == 1
|