diff --git a/test/test_configuration.py b/test/test_configuration.py index ecbaeaf..ad50caf 100644 --- a/test/test_configuration.py +++ b/test/test_configuration.py @@ -2,7 +2,7 @@ from pathlib import Path import pytest -from topen import OPTIONS, parse_cli, parse_env, parse_rc +from topen import OPTIONS, TConf, parse_cli, parse_env, parse_rc class TestCli: @@ -35,6 +35,8 @@ class TestCli: @pytest.fixture def isolate_env(monkeypatch): # delete all existing env vars that could interfere + monkeypatch.delenv("EDITOR", raising=False) + monkeypatch.delenv("VISUAL", raising=False) for opt in OPTIONS.values(): if opt.env: monkeypatch.delenv(opt.env, raising=False) @@ -86,3 +88,22 @@ class TestRcFile: assert rc_cfg["notes_annot"] == "Boo!" assert rc_cfg["notes_editor"] == "micro" assert rc_cfg["notes_quiet"] is True + + +class TestTConf: + def test_paths_are_expanded(self): + cfg = TConf.from_dict( + { + "task_data": "~/somewhere/tasks", + "task_id": 0, + "task_rc": "$HOME/taskrc", + "notes_dir": "$HOME/notes", + } + ) + assert cfg.task_data == Path("~/somewhere/tasks").expanduser() + assert cfg.task_rc == Path("~/taskrc").expanduser() + assert cfg.notes_dir == Path("~/notes").expanduser() + + def test_default_notes_sub_dir(self): + cfg = TConf.from_dict({"task_data": "~/my/tasks", "task_id": 0}) + assert cfg.notes_dir == Path("~/my/tasks/notes").expanduser()