Public Access
feat(meals): suggest complementary sides
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
from types import SimpleNamespace
|
||||
|
||||
from app.models import MealType
|
||||
from app.services.meal_pairings import components_with_suggested_sides, suggest_sides_for_recipe
|
||||
|
||||
|
||||
def _recipe(**kwargs):
|
||||
defaults = {
|
||||
"name": "Grilled Chicken Breast",
|
||||
"protein_type": "chicken",
|
||||
"cuisine_tags": [],
|
||||
"ingredients": [],
|
||||
"side_dishes": [],
|
||||
}
|
||||
defaults.update(kwargs)
|
||||
return SimpleNamespace(**defaults)
|
||||
|
||||
|
||||
def test_simple_protein_gets_vegetable_and_carb_pairing():
|
||||
sides = suggest_sides_for_recipe(_recipe(), MealType.DINNER)
|
||||
|
||||
assert sides is not None
|
||||
assert sides["vegetable"] == "roasted broccoli"
|
||||
assert sides["carb"] == "rice pilaf or roasted potatoes"
|
||||
|
||||
|
||||
def test_complete_meal_does_not_get_extra_pairing():
|
||||
recipe = _recipe(name="Chicken Pasta Bake", protein_type="chicken")
|
||||
|
||||
assert suggest_sides_for_recipe(recipe, MealType.DINNER) is None
|
||||
|
||||
|
||||
def test_breakfast_does_not_get_side_pairing():
|
||||
recipe = _recipe(name="Turkey Sausage", protein_type="turkey")
|
||||
|
||||
assert suggest_sides_for_recipe(recipe, MealType.BREAKFAST) is None
|
||||
|
||||
|
||||
def test_recipe_side_dishes_are_used_when_present():
|
||||
recipe = _recipe(side_dishes=[{"name": "green salad"}, {"name": "garlic bread"}])
|
||||
|
||||
sides = suggest_sides_for_recipe(recipe, "dinner")
|
||||
|
||||
assert sides is not None
|
||||
assert sides["items"] == ["green salad", "garlic bread"]
|
||||
|
||||
|
||||
def test_components_preserve_existing_scores():
|
||||
components = components_with_suggested_sides(
|
||||
_recipe(),
|
||||
MealType.DINNER,
|
||||
{"savings": 0.25},
|
||||
)
|
||||
|
||||
assert components["savings"] == 0.25
|
||||
assert components["suggested_sides"]["needed"] is True
|
||||
Reference in New Issue
Block a user