Extract the individual parsing tests (cli, env, rc) and add additional configuration test file (TConf and config builder). To extract the fixtures they have to go into an additional 'conftest.py' file for pytest to recognize and automatically import them, see: https://docs.pytest.org/en/stable/reference/fixtures.html#conftest-py-sharing-fixtures-across-multiple-files and: https://docs.pytest.org/en/stable/how-to/fixtures.html#using-fixtures-from-other-projects
35 lines
1.4 KiB
Python
35 lines
1.4 KiB
Python
from pathlib import Path
|
|
|
|
from topen import parse_env
|
|
|
|
|
|
class TestEnv:
|
|
def test_env_notes_ext(self, isolate_env, monkeypatch):
|
|
monkeypatch.setenv("TOPEN_NOTES_DIR", "/blablubb")
|
|
monkeypatch.setenv("TOPEN_NOTES_EXT", "rst")
|
|
monkeypatch.setenv("TOPEN_NOTES_ANNOT", "qmd")
|
|
monkeypatch.setenv("TOPEN_NOTES_EDITOR", "vim")
|
|
monkeypatch.setenv("TOPEN_NOTES_QUIET", "true")
|
|
env = parse_env()
|
|
assert env["notes_dir"] == Path("/blablubb")
|
|
assert env["notes_ext"] == "rst"
|
|
assert env["notes_annot"] == "qmd"
|
|
assert env["notes_editor"] == "vim"
|
|
assert env["notes_quiet"] is True
|
|
|
|
def test_env_task_rc(self, isolate_env, monkeypatch):
|
|
monkeypatch.setenv("TASKRC", "/a/dir/that/dont/exist/file")
|
|
monkeypatch.setenv("TASKDATA", "~/somewhere/tasks")
|
|
env = parse_env()
|
|
assert env["task_rc"] == Path("/a/dir/that/dont/exist/file")
|
|
assert env["task_data"] == Path("~/somewhere/tasks")
|
|
|
|
def test_env_parses_boolean_true(self, isolate_env, monkeypatch):
|
|
monkeypatch.setenv("TOPEN_NOTES_QUIET", "true")
|
|
env = parse_env()
|
|
assert env["notes_quiet"] is True
|
|
|
|
def test_env_parses_boolean_false(self, isolate_env, monkeypatch):
|
|
monkeypatch.setenv("TOPEN_NOTES_QUIET", "false")
|
|
env = parse_env()
|
|
assert env["notes_quiet"] is False
|