Public Access
feat: add IngredientCreate/Update/Read and IngredientGroceryMatchRead schemas
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
from decimal import Decimal
|
||||
from uuid import uuid4
|
||||
|
||||
from app.schemas.ingredient import IngredientCreate, IngredientRead, IngredientGroceryMatchRead
|
||||
|
||||
|
||||
def test_ingredient_create_normalizes_aliases() -> None:
|
||||
payload = IngredientCreate(
|
||||
name="Chicken Thighs",
|
||||
aliases=[" chicken thigh ", "BSL chicken thighs", ""],
|
||||
aisle="meat_seafood",
|
||||
unit="lb",
|
||||
)
|
||||
assert payload.name == "Chicken Thighs"
|
||||
assert payload.aliases == ["chicken thigh", "BSL chicken thighs"]
|
||||
|
||||
|
||||
def test_ingredient_match_read_round_trip() -> None:
|
||||
iid = uuid4()
|
||||
gid = uuid4()
|
||||
raw = {
|
||||
"id": uuid4(),
|
||||
"ingredient_id": iid,
|
||||
"grocery_item_id": gid,
|
||||
"confidence": Decimal("0.875"),
|
||||
"source": "auto",
|
||||
"grocery_item_name": "Foster Farms Chicken Thighs Family Pack",
|
||||
"current_price": Decimal("3.99"),
|
||||
"regular_price": Decimal("5.49"),
|
||||
"is_on_sale": True,
|
||||
}
|
||||
parsed = IngredientGroceryMatchRead.model_validate(raw)
|
||||
assert parsed.confidence == Decimal("0.875")
|
||||
assert parsed.is_on_sale is True
|
||||
Reference in New Issue
Block a user