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
from os import environ
2
from pathlib import Path
3
0
0
4
from qbpm.main import main
5
6
7
def test_profile_dir_option(tmp_path: Path):
8
-
main(["-P", str(tmp_path), "new", "test"])
0
0
0
9
assert list(tmp_path.iterdir()) == [tmp_path / "test"]
10
11
12
def test_profile_dir_env(tmp_path: Path):
13
environ["QBPM_PROFILE_DIR"] = str(tmp_path)
14
-
main(["new", "test"])
0
0
0
15
assert list(tmp_path.iterdir()) == [tmp_path / "test"]
16
17
···
19
environ["QBPM_PROFILE_DIR"] = str(tmp_path)
20
session = tmp_path / "test.yml"
21
session.touch()
22
-
main(["from-session", str(session)])
0
0
0
23
assert set(tmp_path.iterdir()) == {session, tmp_path / "test"}
···
1
from os import environ
2
from pathlib import Path
3
4
+
from click.testing import CliRunner
5
+
6
from qbpm.main import main
7
8
9
def test_profile_dir_option(tmp_path: Path):
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")
14
assert list(tmp_path.iterdir()) == [tmp_path / "test"]
15
16
17
def test_profile_dir_env(tmp_path: Path):
18
environ["QBPM_PROFILE_DIR"] = str(tmp_path)
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")
23
assert list(tmp_path.iterdir()) == [tmp_path / "test"]
24
25
···
27
environ["QBPM_PROFILE_DIR"] = str(tmp_path)
28
session = tmp_path / "test.yml"
29
session.touch()
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")
34
assert set(tmp_path.iterdir()) == {session, tmp_path / "test"}