Assistant: codex Assistant-Model: gpt-6-astra Assistant-Session: 01a06e89-93a2-7aa2-82b3-ce5ccd2682e6
83 lines
3.2 KiB
Python
83 lines
3.2 KiB
Python
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from kings_guard.cadence import load_qonto_assistant_source_cadence
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
DRAFT = ROOT / "specs" / "EmissionCadenceDeclaration.md"
|
|
QONTO_SOURCE_DECLARATION = Path("/home/worsch/qonto-assistant/specs/audit-emission-cadence.yaml")
|
|
|
|
|
|
def test_emission_cadence_draft_exists_for_taxonomy_handover() -> None:
|
|
text = DRAFT.read_text(encoding="utf-8")
|
|
assert DRAFT.is_file()
|
|
assert "owner: Taxonomy" in text
|
|
assert "drafter: kings-guard" in text
|
|
assert "qonto-assistant" in text
|
|
assert "GH-WP-0002-T04" in text
|
|
assert "approval-engine/cadence.yaml" in text
|
|
assert "expected rate" in text.lower() or "expected-rate" in text
|
|
assert "heartbeat" in text.lower()
|
|
assert "reconciliation" in text.lower()
|
|
assert "alongside the security genome" in text.lower() or "alongside the genome" in text.lower()
|
|
assert "security_genome" in text
|
|
|
|
|
|
def test_qonto_source_declaration_is_consumed_separately_from_the_taxonomy_draft() -> None:
|
|
cadence = load_qonto_assistant_source_cadence()
|
|
|
|
assert cadence.status == "source-declared"
|
|
assert cadence.owner == "qonto-assistant"
|
|
assert cadence.reference_instance == "QONTO-WP-0005"
|
|
assert cadence.forms() == {"heartbeat-or-reconciliation"}
|
|
assert cadence.rates == ()
|
|
assert cadence.heartbeats[0].interval.total_seconds() == 86400
|
|
|
|
|
|
@pytest.mark.skipif(
|
|
not QONTO_SOURCE_DECLARATION.is_file(),
|
|
reason="qonto-assistant source declaration checkout is unavailable",
|
|
)
|
|
def test_qonto_source_cadence_fixture_matches_the_source_owned_declaration() -> None:
|
|
yaml = pytest.importorskip("yaml")
|
|
source = yaml.safe_load(QONTO_SOURCE_DECLARATION.read_text(encoding="utf-8"))[
|
|
"audit_emission_cadence"
|
|
]
|
|
cadence = load_qonto_assistant_source_cadence()
|
|
|
|
assert cadence.source_system == source["source"]
|
|
assert cadence.heartbeats[0].event_class == source["heartbeat"]["event_class"]
|
|
assert (
|
|
cadence.heartbeats[0].interval.total_seconds()
|
|
== source["heartbeat"]["default_interval_seconds"]
|
|
)
|
|
assert source["event_classes"]["audit.deny"]["form"] in cadence.forms()
|
|
assert source["event_classes"]["audit.allow"]["completeness_claimed"] is False
|
|
assert cadence.rates == ()
|
|
|
|
|
|
@pytest.mark.parametrize("filename", [
|
|
"qonto_assistant_cadence.json", "qonto_assistant_source_cadence.json",
|
|
])
|
|
def test_cadence_fixtures_conform_to_owner_schema(filename):
|
|
import json
|
|
|
|
import jsonschema
|
|
import yaml
|
|
|
|
schema_path = Path(
|
|
"/home/worsch/info-tech-canon/infospace/schemas/emission-cadence.schema.yaml"
|
|
)
|
|
if not schema_path.is_file():
|
|
pytest.skip("canonical InfoTechCanon schema checkout is unavailable")
|
|
schema = yaml.safe_load(schema_path.read_text())
|
|
payload = json.loads((ROOT / "src/kings_guard/fixtures" / filename).read_text())
|
|
jsonschema.Draft202012Validator(schema).validate(payload)
|
|
|
|
|
|
@pytest.mark.parametrize(("value", "seconds"), [("P1DT2H30M5S", 95405), ("P1D", 86400)])
|
|
def test_canonical_compound_durations_are_consumed(value, seconds):
|
|
from kings_guard.cadence import parse_interval
|
|
|
|
assert parse_interval(value).total_seconds() == seconds
|