test: Fix correct cli option value casting

Since we can set the type of the relevant option in the OPTIONS dict, we
should also let the cli correctly cast them on parsing, just as the env
options do.
This commit is contained in:
Marty Oehme 2025-11-28 22:09:13 +01:00
parent bd05dadf56
commit ee8fef930a
Signed by: Marty
GPG key ID: 4E535BC19C61886E
2 changed files with 33 additions and 0 deletions

View file

@ -0,0 +1,32 @@
from pathlib import Path
import pytest
from topen import OPTIONS, parse_cli, parse_env, parse_rc
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",
"--quiet",
"True",
],
)
assert parse_cli() == {
"task_id": "123",
"notes_ext": "txt",
"notes_editor": "vim",
"notes_quiet": True,
}

View file

@ -295,6 +295,7 @@ you view the task.
dest=key,
metavar=opt.metavar,
help=opt.help_text,
type=opt.cast or str,
default=None,
)
args = parser.parse_args()