"""Integration tests: run the installed console scripts as real subprocesses.""" import os import subprocess from pathlib import Path import pytest pytestmark = pytest.mark.integration def test_ops_entry_point_runs_and_greets() -> None: result = subprocess.run( ["nisse-ops"], capture_output=True, text=True, timeout=30, check=False ) assert result.returncode == 0 assert result.stdout == "Hello from nisse-ops, the house spirit is awake.\n" def test_dev_entry_point_refuses_to_start_unconfigured(tmp_path: Path) -> None: """An incomplete config must fail at startup, naming everything absent. Run from an empty directory, with an empty config file and a .env path that does not exist: the repository's .env holds live credentials, and a test must never be one cwd away from starting a real agent. """ config = tmp_path / "nisse-dev.yaml" config.write_text("") result = subprocess.run( ["nisse-dev"], capture_output=True, text=True, timeout=30, check=False, cwd=tmp_path, env={ "PATH": os.environ["PATH"], "HOME": os.environ["HOME"], "NISSE_ENV": "/nonexistent/.env", "NISSE_CONFIG": str(config), }, ) assert result.returncode == 2 assert "cannot start" in result.stderr # All of them at once, not the first one it happened to reach. for expected in ("state_db", "matrix.token", "projects: must name at least one"): assert expected in result.stderr