dodil/erp-brick-ar
DODIL ERP brick: accounts receivable
tests/test_process.py
"""The process this brick serves is the process the customer signed (module.yaml v7 in erp-method): actors and workflows are the
same, so every transition key (the frozen BPMN id) is the signed one. A change goes through a new signature first, then the code."""
import pathlib
import pytest
import yaml
PROCESS = pathlib.Path(__file__).resolve().parents[1] / "src" / "brick_ar" / "application" / "process.yaml"
SPEC = pathlib.Path(__file__).resolve().parents[2] / "erp-method" / "modules" / "ar" / "module.yaml"
@pytest.mark.skipif(not SPEC.exists(), reason="erp-method is not checked out beside this brick")
def test_the_served_process_is_the_signed_module_yaml():
served, spec = yaml.safe_load(PROCESS.read_text()), yaml.safe_load(SPEC.read_text())
assert spec["version"] >= 4 and served["version"] == spec["version"] # a seams-only bump moves both
for key in ("id", "name", "actors", "workflows"):
assert served[key] == spec[key], key
def test_the_v4_transition_keys_are_present():
keys = {t.get("key") for w in yaml.safe_load(PROCESS.read_text())["workflows"] for t in w["transitions"]}
assert {"approve_doubtful_provision", "settle_payment_request", "release_deferred_revenue", "plan_manual_schedule",
"raise_settlement_discount", "record_einvoice_status"} <= keys