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
36 lines
1 KiB
Python
36 lines
1 KiB
Python
from pathlib import Path
|
|
|
|
from topen import parse_rc
|
|
|
|
|
|
class TestRcFile:
|
|
def test_taskrc_parsing(self, fake_rc):
|
|
fake_rc.write_text("""
|
|
data.location=~/.taskies
|
|
notes.dir=/there
|
|
notes.ext=yaml
|
|
notes.annot=Boo!
|
|
notes.editor=micro
|
|
notes.quiet=true
|
|
""")
|
|
rc_cfg = parse_rc(fake_rc)
|
|
assert rc_cfg["task_data"] == Path("~/.taskies")
|
|
assert rc_cfg["notes_dir"] == Path("/there")
|
|
assert rc_cfg["notes_ext"] == "yaml"
|
|
assert rc_cfg["notes_annot"] == "Boo!"
|
|
assert rc_cfg["notes_editor"] == "micro"
|
|
assert rc_cfg["notes_quiet"] is True
|
|
|
|
def test_taskrc_parses_boolean_true(self, fake_rc):
|
|
fake_rc.write_text("""
|
|
notes.quiet=true
|
|
""")
|
|
rc_cfg = parse_rc(fake_rc)
|
|
assert rc_cfg["notes_quiet"] is True
|
|
|
|
def test_taskrc_parses_boolean_false(self, fake_rc):
|
|
fake_rc.write_text("""
|
|
notes.quiet=false
|
|
""")
|
|
rc_cfg = parse_rc(fake_rc)
|
|
assert rc_cfg["notes_quiet"] is False
|