dodil/erp-brick-sales-order
DODIL ERP brick: sales order
tests/test_composition.py
"""The brick composes: `erp-compose check` finds no table or tool collision, no version drift, and a process
view (or its waiver) — with the real business-partner brick when it is installed."""
import pathlib
import pytest
from erp_platform import compose
HERE = pathlib.Path(__file__).parent
def test_the_composition_checks():
pytest.importorskip("brick_bp", reason="brick-business-partner is not installed")
report = compose.check(compose.load(HERE / "tier1.compose.yaml"))
assert report["problems"] == []
def test_the_brick_a_composition_loads_declares_every_route_the_app_serves():
"""compose.yaml points at `brick_sales_order.application.use_cases:SO`: importing that alone (a fresh interpreter, nothing else
imported) must declare the same use cases as the deployable app."""
import subprocess
import sys
code = ("import importlib; b = importlib.import_module('brick_sales_order.application.use_cases').SO; n = len(b.use_cases); "
"importlib.import_module('brick_sales_order.app'); print(n, len(b.use_cases))")
alone, with_app = subprocess.run([sys.executable, "-c", code], capture_output=True, text=True, check=True).stdout.split()
assert alone == with_app, f"the composition's import declares {alone} use cases, the app {with_app}"