-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_config.py
More file actions
31 lines (20 loc) · 962 Bytes
/
test_config.py
File metadata and controls
31 lines (20 loc) · 962 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from collections import OrderedDict
from pathlib import Path
import main
def test_default_value_datafile_dir_is_in_home_folder(mocker) -> None:
expected = Path(Path.home(), ".worktimer")
mocker.patch("main.dotenv_values", return_value=OrderedDict())
main.cfg.reload()
assert main.cfg.datafile_dir == expected
def test_datafile_dir_is_working_dir_if_mode_is_dev(mocker) -> None:
expected = Path(".worktimer")
mocker.patch("main.dotenv_values", return_value=OrderedDict({"mode": "dev"}))
main.cfg.reload()
assert main.cfg.datafile_dir == expected
def test_run_prints_the_app_runs_in_dev_mode_if_dev_mode_set(capsys, mocker) -> None:
mocker.patch("main.dotenv_values", return_value=OrderedDict({"mode": "dev"}))
mocker.patch("builtins.input", return_value="q")
main.cfg.reload()
main.run()
captured = capsys.readouterr()
assert "Running in dev mode." in captured.out