KomandoZentral / tests /test_cli.py
smlflg's picture
Initial public upload from Projekte/KomandoZentral
8f4d2b6 verified
Raw History Blame Contribute Delete
1.55 kB
from __future__ import annotations
import os
import subprocess
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parent.parent
def run_cli(*args: str, cwd: Path | None = None) -> subprocess.CompletedProcess[str]:
env = {"PYTHONPATH": str(ROOT), **os.environ}
return subprocess.run(
[sys.executable, "-m", "kz", *args],
cwd=cwd or ROOT,
capture_output=True,
text=True,
check=False,
env=env,
)
def test_python_module_help_works():
result = run_cli("--help")
assert result.returncode == 0
assert "Task Routing CLI" in result.stdout
def test_python_module_think_request_outputs_yaml():
result = run_cli("Plane", "Phase", "4", "fuer", "Kommandozentrale")
assert result.returncode == 0
assert "task_class: THINK" in result.stdout
assert "harness: Claude Code" in result.stdout
def test_python_module_save_creates_decision(tmp_path):
result = run_cli("Plane", "Release", "--save", cwd=tmp_path)
assert result.returncode == 0
decision_dir = tmp_path / "DECISIONS"
assert decision_dir.exists()
assert any(item.suffix == ".yaml" for item in decision_dir.iterdir())
def test_python_module_save_writes_utf8_yaml(tmp_path):
result = run_cli("Fixe", "Änderung", "im", "Parser", "--save", cwd=tmp_path)
assert result.returncode == 0
decision_file = next((tmp_path / "DECISIONS").glob("*.yaml"))
content = decision_file.read_text(encoding="utf-8")
assert "Änderung" in content
assert "\\x" not in content