|
| 1 | +from __future__ import annotations |
| 2 | + |
| 3 | +import json |
| 4 | +from pathlib import Path |
| 5 | + |
| 6 | +from scripts.generate_layered_admissibility_artifact import ( |
| 7 | + CURVE_ID, |
| 8 | + generate_layered_admissibility_artifact, |
| 9 | +) |
| 10 | +from src.validation.degradation_curve_generator import DegradationCurveGenerator |
| 11 | + |
| 12 | +ARTIFACT_PATH = Path("artifacts/layered_admissibility_results.json") |
| 13 | +CANONICAL_FIXTURE_ID = "coding_workflow_pr_review_moderate_v1" |
| 14 | +CANONICAL_MODERATE_SCORE = 0.8333333333333334 |
| 15 | + |
| 16 | + |
| 17 | +def test_generated_artifact_matches_committed_artifact(tmp_path: Path) -> None: |
| 18 | + output_path = tmp_path / "layered_admissibility_results.json" |
| 19 | + generate_layered_admissibility_artifact(output_path) |
| 20 | + |
| 21 | + generated = json.loads(output_path.read_text(encoding="utf-8")) |
| 22 | + committed = json.loads(ARTIFACT_PATH.read_text(encoding="utf-8")) |
| 23 | + assert generated == committed |
| 24 | + |
| 25 | + |
| 26 | +def test_generated_artifact_has_no_new_top_level_fields() -> None: |
| 27 | + generator = DegradationCurveGenerator() |
| 28 | + curve = generator.generate(generator.fixtures_for_layered_admissibility_curve(), curve_id=CURVE_ID) |
| 29 | + |
| 30 | + generated_top_level = set(generator.to_dict(curve).keys()) |
| 31 | + committed_top_level = set(json.loads(ARTIFACT_PATH.read_text(encoding="utf-8")).keys()) |
| 32 | + assert generated_top_level == committed_top_level |
| 33 | + |
| 34 | + |
| 35 | +def test_moderate_fixture_score_remains_canonical() -> None: |
| 36 | + payload = json.loads(ARTIFACT_PATH.read_text(encoding="utf-8")) |
| 37 | + points = payload["points"] |
| 38 | + moderate_point = next(point for point in points if point["fixture_id"] == CANONICAL_FIXTURE_ID) |
| 39 | + assert moderate_point["overall_admissibility_score"] == CANONICAL_MODERATE_SCORE |
0 commit comments