Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions tests/test_ask_custom.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import pytest

from werk24 import AskCustom, PostprocessorSlot


def test_postprocessor_slot_default_none():
ask = AskCustom(custom_id="foo")
assert ask.postprocessor_slot is None


def test_postprocessor_slot_enum_value():
ask = AskCustom(custom_id="foo", postprocessor_slot=PostprocessorSlot.GREEN)
assert ask.postprocessor_slot == PostprocessorSlot.GREEN


def test_postprocessor_slot_invalid_value():
with pytest.raises(ValueError):
Comment on lines +16 to +17
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Expect Pydantic ValidationError for invalid enum input

The invalid enum case in test_postprocessor_slot_invalid_value asserts that constructing AskCustom with a bad value raises ValueError, but AskCustom is a BaseModel and Pydantic emits a ValidationError when the enum check fails. As written the test will always fail even though the model behaves correctly. Please assert pytest.raises(ValidationError) (or have the model re‑raise) so the test matches the actual API behavior.

Useful? React with 👍 / 👎.

AskCustom(custom_id="foo", postprocessor_slot="red")

7 changes: 6 additions & 1 deletion werk24/models/v2/asks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from pydantic import BaseModel, Field

from werk24.models.v1.ask import W24Ask
from werk24.models.v2.enums import AskType, ThumbnailFileFormat
from werk24.models.v2.enums import AskType, ThumbnailFileFormat, PostprocessorSlot
from werk24.models.v2.models import RedactionKeyword


Expand Down Expand Up @@ -32,13 +32,18 @@ class AskCustom(AskV2):
----------
- custom_id (str): The ID of the custom output to request.
- config (Dict[str, Any]): Configuration options for the custom output.
- postprocessor_slot (Optional[PostprocessorSlot]): The post-processing system to
use for this request.
"""

ask_type: Literal[AskType.CUSTOM] = AskType.CUSTOM
custom_id: str = Field(..., description="The ID of the custom output to request.")
config: Dict[str, Any] = Field(
{}, description="Configuration options for the custom output."
)
postprocessor_slot: Optional[PostprocessorSlot] = Field(
None, description="Select which postprocessing system to use."
)


class AskFeatures(AskV2):
Expand Down
10 changes: 10 additions & 0 deletions werk24/models/v2/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -1394,6 +1394,16 @@ class ThumbnailFileFormat(str, Enum):
"""The output format is PNG."""


class PostprocessorSlot(str, Enum):
"""Enumeration for available postprocessor systems."""

GREEN = "GREEN"
"""Use the green postprocessing system."""

BLUE = "BLUE"
"""Use the blue postprocessing system."""


class PrimaryProcessType(str, Enum):
CUTTING = "CUTTING"
TURNING = "TURNING"
Expand Down
Loading