tangled
alpha
login
or
join now
pvsr.dev
/
qbpm
qutebrowser profile manager
0
fork
atom
overview
issues
pulls
pipelines
cli tests
pvsr.dev
2 years ago
0dfd053e
1ad3b3ab
+14
-3
1 changed file
expand all
collapse all
unified
split
tests
test_main.py
+14
-3
tests/test_main.py
···
1
1
from os import environ
2
2
from pathlib import Path
3
3
4
4
+
from click.testing import CliRunner
5
5
+
4
6
from qbpm.main import main
5
7
6
8
7
9
def test_profile_dir_option(tmp_path: Path):
8
8
-
main(["-P", str(tmp_path), "new", "test"])
10
10
+
runner = CliRunner()
11
11
+
result = runner.invoke(main, ["-P", str(tmp_path), "new", "test"])
12
12
+
assert result.exit_code == 0
13
13
+
assert result.output.strip() == str(tmp_path / "test")
9
14
assert list(tmp_path.iterdir()) == [tmp_path / "test"]
10
15
11
16
12
17
def test_profile_dir_env(tmp_path: Path):
13
18
environ["QBPM_PROFILE_DIR"] = str(tmp_path)
14
14
-
main(["new", "test"])
19
19
+
runner = CliRunner()
20
20
+
result = runner.invoke(main, ["new", "test"])
21
21
+
assert result.exit_code == 0
22
22
+
assert result.output.strip() == str(tmp_path / "test")
15
23
assert list(tmp_path.iterdir()) == [tmp_path / "test"]
16
24
17
25
···
19
27
environ["QBPM_PROFILE_DIR"] = str(tmp_path)
20
28
session = tmp_path / "test.yml"
21
29
session.touch()
22
22
-
main(["from-session", str(session)])
30
30
+
runner = CliRunner()
31
31
+
result = runner.invoke(main, ["from-session", str(session)])
32
32
+
assert result.exit_code == 0
33
33
+
assert result.output.strip() == str(tmp_path / "test")
23
34
assert set(tmp_path.iterdir()) == {session, tmp_path / "test"}