Files
mealie/tests/unit_tests/test_step_cooking_schema.py
T
jfmcarreira 05cfb98ceb
Release Drafter / auto_label (push) Skipped
Backend Lint and Test / tests (sqlite) (push) Canceled after 0s
Backend Lint and Test / tests (postgres) (push) Canceled after 0s
Docker Nightly Production / Backend Server Tests (push) Canceled after 0s
Frontend Lint and Test / lint (push) Canceled after 0s
Docker Nightly Production / Frontend Tests (push) Canceled after 0s
Build Package / Build frontend and wheel (push) Canceled after 0s
Docker Nightly Production / Build Package (push) Canceled after 0s
Docker Nightly Production / Build E2E Image Cache (push) Canceled after 0s
Docker Nightly Production / Build Tagged Release (push) Canceled after 0s
Docker Nightly Production / Notify Discord (push) Canceled after 0s
CodeQL / Analyze (javascript-typescript) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
Release Drafter / draft_release (push) Canceled after 0s
feat(recipe): add step quantities and appliance settings
2026-11-30 14:44:17 +00:00

34 lines
1.1 KiB
Python

import pytest
from pydantic import ValidationError
from mealie.schema.recipe.recipe_step import IngredientReferences, RecipeStep, StepCooking
def test_legacy_step_and_explicit_zero():
step = RecipeStep(text="Mix", ingredient_references=[IngredientReferences(quantity=0)])
assert step.cooking is None
assert step.ingredient_references[0].quantity == 0
assert IngredientReferences().quantity is None
@pytest.mark.parametrize("speed", [1, 0.5, "spoon"])
def test_cooking_speeds(speed):
assert StepCooking(speed=speed).speed == speed
@pytest.mark.parametrize("quantity", [-1, float("inf"), float("nan")])
def test_invalid_quantity(quantity):
with pytest.raises(ValidationError):
IngredientReferences(quantity=quantity)
def test_nonfinite_speed_rejected():
with pytest.raises(ValidationError):
StepCooking(speed=float("inf"))
def test_unknown_cooking_settings_are_not_silently_discarded():
with pytest.raises(ValidationError):
StepCooking.model_validate({"speed": 2, "reverse": True})
assert "reverse" not in StepCooking.model_json_schema(by_alias=True)["properties"]