forked from ChelseaKR/outcome-receipts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_release_compatibility.py
More file actions
52 lines (41 loc) · 2.13 KB
/
Copy pathtest_release_compatibility.py
File metadata and controls
52 lines (41 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
"""Compatibility evidence frozen from the signed v0.1.0 release."""
from __future__ import annotations
import json
from pathlib import Path
from outcome_receipts.clock import FixedClock
from outcome_receipts.config import SPEC_SCHEMA_VERSION, load_spec
from outcome_receipts.engine import compute_figures, read_csv
from outcome_receipts.models import SCHEMA_VERSION
from outcome_receipts.suppression import suppress_figures
from outcome_receipts.verify import verify_manifest
ROOT = Path(__file__).resolve().parents[1]
BASELINE = ROOT / "tests" / "fixtures" / "compat" / "v0.1.0"
def test_current_code_rederives_signed_v010_receipt_manifest() -> None:
spec = load_spec(BASELINE / "report.toml")
figures = compute_figures(
read_csv(spec.data_path),
spec.report.metrics,
clock=FixedClock(),
data_checks=spec.report.data_checks,
)
publishable, suppression = suppress_figures(figures)
manifest = json.loads((BASELINE / "receipts.json").read_text(encoding="utf-8"))
result = verify_manifest(publishable, manifest)
assert spec.schema_version == SPEC_SCHEMA_VERSION
assert suppression.ok
assert result.ok
# The baseline is a manifest-schema 1.0 document, which is no longer what
# this package writes: 2.0 withholds a suppressed receipt's numerics as null
# where 1.0 wrote zeros. Assert the older shape is really what was read, so
# this cannot start passing vacuously if the fixture is ever regenerated.
assert manifest["schema_version"] == "1.0"
assert manifest["schema_version"] != SCHEMA_VERSION
withheld = [record for record in manifest["receipts"] if record["value"] == 0.0]
assert withheld, "the baseline no longer exercises the 1.0 suppressed rendering"
assert all("suppressed" not in record for record in manifest["receipts"])
assert any(figure.receipt.suppressed for figure in publishable)
def test_v010_baseline_names_immutable_source_commit() -> None:
source = (BASELINE / "SOURCE.md").read_text(encoding="utf-8")
assert "v0.1.0" in source
assert "51d18fc4cdd9f9dcd91dd4588ededc80a6b6bb7d" in source
assert "byte-for-byte copies" in source