From 0cec8c42c0a3c994285b93db5ee2881042586672 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Gon=C3=A7alves?= Date: Thu, 6 Oct 2022 22:33:48 +0200 Subject: wip: decorator + arguments tests --- tests/test_core.py | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) (limited to 'tests/test_core.py') diff --git a/tests/test_core.py b/tests/test_core.py index 5993abc..cc4755f 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -1,8 +1,38 @@ +import click +import pickle import pytest -from pydanclick import core, schemas -from tests.conftest import GenericArguments +def test_get_option_arguments_ok(valid_arguments): + # core.get_option_arguments(schema, parameter, "mega-option") + pass -def test_get_option_arguments_ok(): - core.get_option_arguments() + +def test_generate_cli_options_start(valid_command_entrypoint): + + with pytest.raises(SystemExit): + valid_command_entrypoint() + + +@pytest.mark.parametrize( + "argument_info", + [ + ["name", ["--name"], click.STRING], + ["version", ["--version"], click.IntRange(min=0)], + ["force", ["--force"], click.BOOL], + ["fruit", ["--fruit"], click.STRING], + ] +) +def test_generate_cli_options_arguments( + valid_command_entrypoint, + argument_info, +): + option = next( + filter( + lambda el: el.name == argument_info[0], + valid_command_entrypoint.params + ) + ) + + assert option.opts == argument_info[1] + assert pickle.dumps(option.type) == pickle.dumps(argument_info[2]) -- cgit v1.2.3