dodil/erp-brick-tax
DODIL ERP brick: tax
tests/test_process.py
"""The process this brick serves is the process the customer SIGNED on 2026-10-25 (tax v6: all ten workflows). A change to process.yaml that changes the process breaks this test — the change goes through
`erp-compose change propose` and a new signature first, then the code. The view is drawn under the spec's own name,
module.yaml, to compare (the generated BPMN's documentation names its source file inside the hash)."""
import pathlib
import yaml
from erp_platform import bpmn, signoff
PROCESS = pathlib.Path(__file__).resolve().parents[1] / "src" / "brick_tax" / "application" / "process.yaml"
SIGNED = {"registration": "07eea662f3984a83084a71ed4e915f5632d21d519f88f3b3eb8a8ae0603be67b", "tax_code": "8643825b8fbf58b7a0439404128a9c6c79daa4d3f6b5eec06ff781e76d0a0fc9", "document_tax": "a639ed281e92e1480bb7d01f28bf81b48e2a61fdb28d8cc66d0ab11f479a0b75", "party_tax": "ef43759433a76bc91312cb2249c24cb5ad0e0c24d3f8d6602cbfdd8bac8d8a03", "vat_return": "1c214f6d8bacb4c8f1f1044550925e49e3a1daf900f118a08e02d8008986eb5c", "bad_debt_claim": "7a95c033de227912e65f0545d73826b326b201caab6c7669cab136ce17144766", "cis_subcontractor": "ebdcbc9348542c0ac8659479df809b0f6b3f7e0ecc094b60d72bf6affee2a916", "cis_return": "ba051f513244c019ffd29749a5848f6efd71c20f7085e29f7382a9ba48400c29", "trade_declaration": "d13fc218216e6880e2a3babea1b67695bb7d437970135968ad669fc254522a9f", "pva_statement": "a234c7b500600ff0fa8f849ef9bc7efe34da05b58e6988904f50df8be6e9e8b5"}
def drawn(entity: str, data=None) -> str:
spec = bpmn.from_module(data or yaml.safe_load(PROCESS.read_text()), "module.yaml")
spec.workflows = [w for w in spec.workflows if w.entity == entity]
return bpmn.to_bpmn(spec)
def test_the_served_process_is_the_signed_one():
for entity, sha in SIGNED.items():
assert signoff.matches(sha, drawn(entity), "module.yaml") is not None, entity
def test_a_changed_process_does_not_match():
"""The guard is real: one renamed step and the signature no longer matches."""
data = yaml.safe_load(PROCESS.read_text())
data["workflows"][0]["transitions"][0]["name"] = "Add whatever we like"
assert signoff.matches(SIGNED["registration"], drawn("registration", data), "module.yaml") is None