"""Run the shipped demo end-to-end as a subprocess. The demo (demo/run_demo.py) walks one amendment through ratification and shows another being blocked by the vote gate. It is the canonical integration test of the whole pipeline: if it exits non-zero, the milestone's headline claim is broken. """ from __future__ import annotations from tests.helpers import PROJECT_ROOT, run_script def test_demo_runs_clean(): result = run_script(PROJECT_ROOT / "demo" / "run_demo.py", cwd=PROJECT_ROOT) assert result.returncode == 0, ( f"demo exited {result.returncode}\n--- stdout ---\n{result.stdout}\n" f"--- stderr ---\n{result.stderr}" ) assert result.stdout.strip(), "the demo should narrate what it is doing" def test_demo_is_idempotent(): """Running the demo twice must not corrupt anything or fail the second time.""" first = run_script(PROJECT_ROOT / "demo" / "run_demo.py", cwd=PROJECT_ROOT) second = run_script(PROJECT_ROOT / "demo" / "run_demo.py", cwd=PROJECT_ROOT) assert first.returncode == 0, first.stderr assert second.returncode == 0, second.stderr