Files
bot-bottle/tests/unit/test_cli_start_format.py
T
didericis 95a14bb8d2
test / unit (push) Successful in 11s
test / integration (push) Failing after 11s
style: pass explicit check= to every subprocess.run call
Silences pylint W1510 / ruff PLW1510 across the codebase. The choice
at each site reflects existing intent:

- check=True where the caller implicitly trusts success (docker ps /
  network ls returning stdout, docker build, exec chown/chmod inside
  provisioners).
- check=False where the caller inspects .returncode (race-retry on
  docker run, pipelock sidecar lifecycle, network plumbing, exec_claude
  propagating the session's exit code, best-effort cleanup paths).

No behavior change; check= defaults to False so the False sites are
semantically identical.
2026-05-12 10:13:56 -04:00

55 lines
1.7 KiB
Python

"""Unit: argparse-level CLI checks for `start --format`.
Lives in tests/unit/ because nothing here touches Docker — the CLI
exits at argument-validation time before any backend code runs.
"""
import json
import os
import subprocess
import sys
import tempfile
import unittest
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parent.parent.parent
class TestStartFormatFlag(unittest.TestCase):
def test_json_format_requires_dry_run(self):
"""Emitting JSON in a real run would race the y/N prompt; the
CLI must reject the combination with a message that names the
offending flag."""
work_dir = Path(tempfile.mkdtemp())
try:
(work_dir / "claude-bottle.json").write_text(json.dumps({
"bottles": {"dev": {}},
"agents": {"demo": {"skills": [], "prompt": "", "bottle": "dev"}},
}))
env = os.environ.copy()
env["HOME"] = str(work_dir)
env.pop("CLAUDE_BOTTLE_DRY_RUN", None)
result = subprocess.run(
[
sys.executable, str(REPO_ROOT / "cli.py"),
"start", "--format", "json", "demo",
],
cwd=work_dir,
env=env,
capture_output=True,
text=True,
check=False,
)
self.assertNotEqual(0, result.returncode)
self.assertIn(
"--format=json requires --dry-run", result.stderr,
f"expected the flag-conflict message; got stderr={result.stderr!r}",
)
finally:
import shutil
shutil.rmtree(work_dir, ignore_errors=True)
if __name__ == "__main__":
unittest.main()