"""CLI integration test for --llm-report flag (P5.3 T5).""" from __future__ import annotations from pathlib import Path import pytest from pf1e_simulator.cli import main ROOT = Path(__file__).resolve().parents[1] MAP = ROOT / "data" / "maps" / "sample_arena.yaml" def _argv_common() -> list[str]: return [ "--map", str(MAP), "--side", "players", str(ROOT / "data" / "monsters" / "goblin.json"), "--side", "monsters", str(ROOT / "data" / "monsters" / "orc.json"), ] def test_cli_llm_report_mutually_exclusive_with_transcript() -> None: """--llm-report and --transcript are mutually exclusive.""" argv = [*_argv_common(), "--llm-report", "--transcript"] with pytest.raises(SystemExit) as exc_info: main(argv) assert exc_info.value.code == 2 def test_cli_output_requires_llm_report() -> None: """--output requires --llm-report.""" argv = [*_argv_common(), "--output", "report.md"] with pytest.raises(SystemExit) as exc_info: main(argv) assert exc_info.value.code == 2 def test_cli_llm_report_requires_api_key_env(monkeypatch: pytest.MonkeyPatch) -> None: """--llm-report fails gracefully when PF1E_LLM_API_KEY not set.""" monkeypatch.delenv("PF1E_LLM_API_KEY", raising=False) monkeypatch.delenv("PF1E_PROMPT_PACK_DIR", raising=False) argv = [*_argv_common(), "--llm-report"] with pytest.raises(SystemExit) as exc_info: main(argv) assert exc_info.value.code == 2 def test_cli_llm_report_requires_prompt_pack_dir(monkeypatch: pytest.MonkeyPatch) -> None: """--llm-report fails gracefully when PF1E_PROMPT_PACK_DIR not set.""" monkeypatch.setenv("PF1E_LLM_API_KEY", "test-key") monkeypatch.delenv("PF1E_PROMPT_PACK_DIR", raising=False) argv = [*_argv_common(), "--llm-report"] with pytest.raises(SystemExit) as exc_info: main(argv) assert exc_info.value.code == 2