Skip to content

Commit 0dfd053

Browse files
committed
cli tests
1 parent 1ad3b3a commit 0dfd053

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

tests/test_main.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,34 @@
11
from os import environ
22
from pathlib import Path
33

4+
from click.testing import CliRunner
5+
46
from qbpm.main import main
57

68

79
def test_profile_dir_option(tmp_path: Path):
8-
main(["-P", str(tmp_path), "new", "test"])
10+
runner = CliRunner()
11+
result = runner.invoke(main, ["-P", str(tmp_path), "new", "test"])
12+
assert result.exit_code == 0
13+
assert result.output.strip() == str(tmp_path / "test")
914
assert list(tmp_path.iterdir()) == [tmp_path / "test"]
1015

1116

1217
def test_profile_dir_env(tmp_path: Path):
1318
environ["QBPM_PROFILE_DIR"] = str(tmp_path)
14-
main(["new", "test"])
19+
runner = CliRunner()
20+
result = runner.invoke(main, ["new", "test"])
21+
assert result.exit_code == 0
22+
assert result.output.strip() == str(tmp_path / "test")
1523
assert list(tmp_path.iterdir()) == [tmp_path / "test"]
1624

1725

1826
def test_from_session(tmp_path: Path):
1927
environ["QBPM_PROFILE_DIR"] = str(tmp_path)
2028
session = tmp_path / "test.yml"
2129
session.touch()
22-
main(["from-session", str(session)])
30+
runner = CliRunner()
31+
result = runner.invoke(main, ["from-session", str(session)])
32+
assert result.exit_code == 0
33+
assert result.output.strip() == str(tmp_path / "test")
2334
assert set(tmp_path.iterdir()) == {session, tmp_path / "test"}

0 commit comments

Comments
 (0)