test: Restructure test files
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:
parent
ff0e6cccfb
commit
13c34b08e2
6 changed files with 224 additions and 114 deletions
48
test/test_parse_cli.py
Normal file
48
test/test_parse_cli.py
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
from pathlib import Path
|
||||
|
||||
from topen import parse_cli
|
||||
|
||||
|
||||
class TestCli:
|
||||
def test_cli_minimum_id(self, monkeypatch):
|
||||
monkeypatch.setattr("sys.argv", ["topen", "42"])
|
||||
assert parse_cli() == {"task_id": "42"}
|
||||
|
||||
def test_cli_options(self, monkeypatch):
|
||||
monkeypatch.setattr(
|
||||
"sys.argv",
|
||||
[
|
||||
"topen",
|
||||
"123",
|
||||
"--extension",
|
||||
"txt",
|
||||
"--editor",
|
||||
"vim",
|
||||
"--annotation",
|
||||
"HERENOTE",
|
||||
],
|
||||
)
|
||||
assert parse_cli() == {
|
||||
"task_id": "123",
|
||||
"notes_ext": "txt",
|
||||
"notes_editor": "vim",
|
||||
"notes_annot": "HERENOTE",
|
||||
}
|
||||
|
||||
def test_cli_notes_quiet_is_flag(self, monkeypatch):
|
||||
monkeypatch.setattr(
|
||||
"sys.argv",
|
||||
[
|
||||
"topen",
|
||||
"123",
|
||||
"--quiet",
|
||||
],
|
||||
)
|
||||
assert parse_cli()["notes_quiet"] is True
|
||||
|
||||
def test_cli_parses_paths(self, monkeypatch):
|
||||
monkeypatch.setattr(
|
||||
"sys.argv",
|
||||
["topen", "123", "--notes-dir", "/somewhere/else"],
|
||||
)
|
||||
assert parse_cli()["notes_dir"] == Path("/somewhere/else")
|
||||
Loading…
Add table
Add a link
Reference in a new issue