feat(schemas): add Station and assignment Pydantic schemas
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
"""Tests for Station Pydantic schemas."""
|
||||
import pytest
|
||||
from pydantic import ValidationError
|
||||
|
||||
from schemas.station import (
|
||||
StationCreate, StationUpdate, StationResponse,
|
||||
StationRecipeAssignmentCreate, StationRecipeAssignmentResponse,
|
||||
StationWithRecipesResponse,
|
||||
)
|
||||
|
||||
|
||||
def test_station_create_valid():
|
||||
data = StationCreate(code="ST-001", name="Linea 1", location="Reparto Nord")
|
||||
assert data.code == "ST-001"
|
||||
assert data.active is True
|
||||
|
||||
|
||||
def test_station_create_rejects_empty_code():
|
||||
with pytest.raises(ValidationError):
|
||||
StationCreate(code="", name="X")
|
||||
|
||||
|
||||
def test_station_create_rejects_too_long_code():
|
||||
with pytest.raises(ValidationError):
|
||||
StationCreate(code="A" * 101, name="X")
|
||||
|
||||
|
||||
def test_station_update_all_optional():
|
||||
data = StationUpdate()
|
||||
assert data.name is None
|
||||
|
||||
|
||||
def test_station_assignment_create():
|
||||
data = StationRecipeAssignmentCreate(recipe_id=42)
|
||||
assert data.recipe_id == 42
|
||||
Reference in New Issue
Block a user