Initial commit
This commit is contained in:
40
tests/test_cli.py
Normal file
40
tests/test_cli.py
Normal file
@@ -0,0 +1,40 @@
|
||||
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
|
||||
Reference in New Issue
Block a user