1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
import click
import pytest
from enum import Enum
from pydantic import BaseModel, Field
from pydanclick import core, decorators
from typing import Generator
class GenericArguments(BaseModel):
class FruitEnum(str, Enum):
apple = "apple"
banana = "banana"
pineapple = "pineapple"
name: str = Field(min_length=10)
version: int = Field(gt=0)
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]:
yield GenericArguments(
name="fruit_manager",
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]:
@decorators.command()
def entrypoint(parameters: GenericArguments):
pass
yield entrypoint
|