blob: 7d5e2c7be8f1c85504c304a4d9f265d6cee8fde1 (
plain) (
tree)
|
|
import click
import pytest
from enum import Enum
from pydantic import BaseModel, Field
from pydanclick import core
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
@pytest.fixture
def valid_arguments() -> Generator[GenericArguments, None, None]:
yield GenericArguments(
name="fruit_manager",
version=12,
force=True,
fruit="pineapple",
)
@pytest.fixture
def valid_command_entrypoint() -> Generator[click.Command, None, None]:
@click.command()
@core.generate_cli_options()
def entrypoint(parameters: GenericArguments):
pass
yield entrypoint
|