topen/test/test_parse_cli.py
Marty Oehme 13c34b08e2
Some checks are pending
website / deploy (push) Blocked by required conditions
website / build (push) Waiting to run
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
2025-11-29 12:29:35 +01:00

48 lines
1.2 KiB
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_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")