import importlib.util from pathlib import Path SPEC = importlib.util.spec_from_file_location( "audit_core_e2_runner", Path("runners/audit_core_e2.py") ) runner = importlib.util.module_from_spec(SPEC) assert SPEC.loader is not None SPEC.loader.exec_module(runner) def test_equivalent_denial_includes_digest(): base = { "status": 404, "content_type": "application/json", "count": 1, "schema": ["$", "$.error:str"], "run_digest": "same", } assert runner.equivalent(base, dict(base)) changed = dict(base, run_digest="different") assert not runner.equivalent(base, changed) def test_event_is_synthetic_and_correlation_bound(): payload = runner.event("event-a", "tenant-a", "corr") assert payload["id"] == payload["data"]["fixture_id"] assert payload["tenant"] == "tenant-a" assert payload["correlation_id"] == "corr" def test_p95_is_conservative_for_small_runs(): assert runner._p95([10, 20, 30]) == 30