Files
applepy/tests/test_cli.py
Warezpeddler 3325436017 Initial commit
2026-04-25 23:09:31 +01:00

41 lines
1.1 KiB
Python

import pytest
from applepy.cli import _build_parser, main
def test_help_text_documents_privilege_and_sudo() -> None:
text = _build_parser().format_help()
assert "Without sudo" in text
assert "With sudo" in text
assert "unprivileged" in text.lower()
def test_help_exits_zero() -> None:
with pytest.raises(SystemExit) as e:
main(["--help"])
assert e.value.code == 0
with pytest.raises(SystemExit) as e2:
main(["-h"])
assert e2.value.code == 0
def test_version() -> None:
with pytest.raises(SystemExit) as e:
main(["--version"])
assert e.value.code == 0
def test_conflicting_flags() -> None:
assert main(["--unprivileged-only", "--privileged-only"]) == 2
def test_bootstrap_compliance_flag(monkeypatch: pytest.MonkeyPatch) -> None:
from pathlib import Path
def fake_run(root: Path) -> tuple[int, list[str]]:
assert isinstance(root, Path)
return 0, ["bootstrap_ok"]
monkeypatch.setattr("applepy.bootstrap_compliance.run_full_bootstrap", fake_run)
assert main(["--bootstrap-compliance"]) == 0