"""Integration tests: run the installed console scripts as real subprocesses.""" import os import subprocess 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() -> None: """Missing configuration must fail at startup, naming everything absent. Run with a deliberately empty environment and a .env path that does not exist: the real .env in the working directory holds live credentials, and a test must never be one cwd away from starting a real agent. """ result = subprocess.run( ["nisse-dev"], capture_output=True, text=True, timeout=30, check=False, env={ "PATH": os.environ["PATH"], "HOME": os.environ["HOME"], "NISSE_ENV": "/nonexistent/.env", }, ) 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 ("NISSE_STATE_DB", "NISSE_MATRIX_TOKEN", "NISSE_GITEA_REPO"): assert expected in result.stderr