Coverage for src/counter_os/application/dtos/counter_set_request.py: 100%
10 statements
« prev ^ index » next coverage.py v7.17.5, created at 2026-11-29 05:31 -0600
« prev ^ index » next coverage.py v7.17.5, created at 2026-11-29 05:31 -0600
1from dataclasses import dataclass
2from typing import Any
4from counter_os.domain.value_objects.count import Count
7@dataclass(frozen=True)
8class CounterSetRequest:
9 count: int
11 def __post_init__(self) -> None:
12 """Validate request data.
14 Note that Domain errors are raised during to_execution_params(),
15 so this is not the place to enforce Domain invariants.
16 Instead this is just the place to ensure incoming data is formatted
17 and structured correctly."""
18 if type(self.count) != int:
19 raise ValueError("Count must be an integer")
21 def to_execution_params(self) -> dict[str, Any]:
22 """Convert validated request data to use_case parameters"""
23 return {"count": Count(self.count)}