Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""CLI integration tests."""

import json
import re
from pathlib import Path

from typer.testing import CliRunner
Expand All @@ -9,6 +10,14 @@

runner = CliRunner()
REPO_ROOT = Path(__file__).resolve().parents[1]
_ANSI = re.compile(r"\x1b\[[0-9;]*[A-Za-z]")


def _plain(result) -> str:
raw = "".join(
part for part in (result.output, getattr(result, "stdout", ""), getattr(result, "stderr", "") or "") if part
)
return _ANSI.sub("", raw)


def test_demo_exits_zero_and_writes_json(tmp_path: Path, monkeypatch) -> None:
Expand Down Expand Up @@ -52,12 +61,12 @@ def test_run_requires_api_key_for_gemini(tmp_path: Path, monkeypatch) -> None:
assert "GEMINI_API_KEY" in result.output


def test_run_help_lists_provider_flags() -> None:
result = runner.invoke(app, ["run", "--help"])
assert result.exit_code == 0
assert "--provider" in result.output
assert "--model" in result.output
assert "--ollama-host" in result.output
assert "--exit-on-loss" in result.output
assert "--min-win-rate" in result.output
assert "--swap-order" in result.output
def test_run_help_lists_provider_flags(monkeypatch) -> None:
monkeypatch.setenv("COLUMNS", "200")
monkeypatch.setenv("NO_COLOR", "1")
monkeypatch.setenv("TERM", "dumb")
result = runner.invoke(app, ["run", "--help"], env={"COLUMNS": "200", "NO_COLOR": "1", "TERM": "dumb"})
assert result.exit_code == 0, result.output
text = re.sub(r"\s+", "", _plain(result))
for flag in ("--provider", "--model", "--ollama-host", "--exit-on-loss", "--min-win-rate", "--swap-order"):
assert flag in text, _plain(result)
Loading