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
37 lines
998 B
Python
37 lines
998 B
Python
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_parses_paths(self, monkeypatch):
|
|
monkeypatch.setattr(
|
|
"sys.argv",
|
|
["topen", "123", "--notes-dir", "/somewhere/else"],
|
|
)
|
|
assert parse_cli()["notes_dir"] == Path("/somewhere/else")
|