diff options
author | Romain Gonçalves <me@rgoncalves.se> | 2022-10-06 22:55:40 +0200 |
---|---|---|
committer | Romain Gonçalves <me@rgoncalves.se> | 2022-10-06 22:55:40 +0200 |
commit | e667cd7e2dd0a7ac14ac30db38ca630ec0c5409b (patch) | |
tree | a491226d5a7ee4c41fbe758d59550d2d011a3272 | |
parent | 0cec8c42c0a3c994285b93db5ee2881042586672 (diff) | |
download | pydanclick-e667cd7e2dd0a7ac14ac30db38ca630ec0c5409b.tar.gz |
fixup! wip: decorator + arguments tests
-rw-r--r-- | pydanclick/decorators.py | 1 | ||||
-rw-r--r-- | tests/conftest.py | 14 | ||||
-rw-r--r-- | tests/test_core.py | 12 |
3 files changed, 22 insertions, 5 deletions
diff --git a/pydanclick/decorators.py b/pydanclick/decorators.py index eddb50e..b1e7522 100644 --- a/pydanclick/decorators.py +++ b/pydanclick/decorators.py @@ -9,6 +9,7 @@ from pydanclick.core import ( get_parameters_from_arguments, ) + def command( name: str = None, cls: type = Command, diff --git a/tests/conftest.py b/tests/conftest.py index 7d5e2c7..18f540a 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -3,7 +3,7 @@ import pytest from enum import Enum from pydantic import BaseModel, Field -from pydanclick import core +from pydanclick import core, decorators from typing import Generator @@ -19,6 +19,11 @@ class GenericArguments(BaseModel): force: bool = Field(default=False, description="Force ABC.") fruit: FruitEnum + integer_gt_lt: int = Field(gt=16, lt=64) + integer_ge_le: int = Field(ge=16, le=64) + integer_gt_le: int = Field(gt=16, le=64) + integer_ge_lt: int = Field(ge=16, lt=64) + @pytest.fixture def valid_arguments() -> Generator[GenericArguments, None, None]: @@ -27,14 +32,17 @@ def valid_arguments() -> Generator[GenericArguments, None, None]: version=12, force=True, fruit="pineapple", + integer_gt_lt=20, + integer_ge_le=21, + integer_gt_le=22, + integer_ge_lt=23, ) @pytest.fixture def valid_command_entrypoint() -> Generator[click.Command, None, None]: - @click.command() - @core.generate_cli_options() + @decorators.command() def entrypoint(parameters: GenericArguments): pass diff --git a/tests/test_core.py b/tests/test_core.py index cc4755f..d85a6e6 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -2,16 +2,24 @@ import click import pickle import pytest +from pydanclick import core +from tests import conftest + def test_get_option_arguments_ok(valid_arguments): # core.get_option_arguments(schema, parameter, "mega-option") pass -def test_generate_cli_options_start(valid_command_entrypoint): +def test_generate_cli_options_start(): + + @click.command() + @core.generate_cli_options() + def entrypoint(parameters: conftest.GenericArguments): + pass with pytest.raises(SystemExit): - valid_command_entrypoint() + entrypoint() @pytest.mark.parametrize( |