dodil/erp-brick-pos

DODIL ERP brick: point of sale

tests/test_scenarios.py

"""The scenario catalogue covers every scenario in the spec (module.yaml tests.scenarios)."""
import pathlib
import sys

import pytest

sys.path.insert(0, str(pathlib.Path(__file__).parent / "scenarios"))

import catalogue  # noqa: E402

SPEC = ["SC-POS-01", "SC-POS-02", "SC-POS-03", "SC-POS-04", "SC-POS-05"]


def test_the_catalogue_covers_the_spec():
    assert [sc.id for sc in catalogue.CAT.scenarios] == SPEC


def test_the_catalogue_runs_in_process():
    """The whole composition in process: storage wires, the generated probes pass, nothing errors (a scenario
    still to write is skipped)."""
    pytest.importorskip("brick_bp", reason="brick-business-partner is not installed")
    from erp_platform.scenarios.inprocess import InProcessRunner
    runner = InProcessRunner(catalogue.CAT)
    runner.start()
    try:
        results = runner.run_all()
    finally:
        runner.stop()
    assert [(r.id, r.outcome, r.message[:300]) for r in results if r.outcome in ("failed", "error")] == []
    assert any(r.id.startswith("PROBE-PERM-") and r.outcome == "passed" for r in results)