test: Restructure test files
Some checks are pending
website / deploy (push) Blocked by required conditions
website / build (push) Waiting to run

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
This commit is contained in:
Marty Oehme 2025-11-29 11:18:48 +01:00
parent ff0e6cccfb
commit 13c34b08e2
Signed by: Marty
GPG key ID: 4E535BC19C61886E
6 changed files with 224 additions and 114 deletions

36
test/test_parse_rc.py Normal file
View file

@ -0,0 +1,36 @@
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