from unittest.mock import patch from click.testing import CliRunner from hqt import cli as cli_module from hqt import sandbox from hqt.cli import main def _which(found: set[str]): return lambda name: f"/usr/bin/{name}" if name in found else None def test_doctor_reports_bwrap_present(): """Test that doctor reports bubblewrap when present.""" # tmux is discovered via cli.shutil.which; bwrap availability comes from the # shared sandbox.is_available() helper (the single source of truth). with ( patch.object(cli_module.shutil, "which", side_effect=_which({"tmux", "bwrap"})), patch.object(sandbox, "is_available", return_value=True), ): result = CliRunner().invoke(main, ["doctor"]) assert result.exit_code == 0 assert "bubblewrap: ✓" in result.output def test_doctor_reports_bwrap_missing(): """Test that doctor reports bubblewrap as missing when not present.""" with ( patch.object(cli_module.shutil, "which", side_effect=_which({"tmux"})), patch.object(sandbox, "is_available", return_value=False), ): result = CliRunner().invoke(main, ["doctor"]) assert result.exit_code == 0 assert "bubblewrap: ✗" in result.output