topen/test/test_parse_cli.py
Marty Oehme 1ea149c1de
fix: Ensure quiet is a flag on the cli
We regressed quiet into requiring a value to be set as a cli option
(`--quiet=true`) instead of just functioning as a flag (`--quiet`). This
change restores the previous interface on the command line,
and adds a test to ensure no regressions.
2025-11-29 21:10:12 +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")