mitai-jinkendo/backend/tests/test_food_recipes.py
Lars a5adff6196
All checks were successful
Deploy Development / deploy (push) Successful in 59s
Build Test / pytest-backend (push) Successful in 4s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 23s
feat: Zutaten im Listendialog dem BLS zuordnen
Mapping-Status pro Zutat, Suche zuerst Listen und eigene Foods.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-13 14:38:42 +02:00

31 lines
1000 B
Python

from data_layer.food_recipes import list_known_ingredient_names, save_recipe
class _FakeCur:
def __init__(self, rows):
self.rows = rows
def execute(self, sql, params=None):
return None
def fetchall(self):
return self.rows
def test_known_ingredient_names_flags_mapping():
rows = list_known_ingredient_names(_FakeCur([
{"source_name_raw": "Hafer", "source_name_normalized": "hafer", "food_id": "1", "food_name_de": "Haferflocken", "bls_code": "B123", "mapped": True},
{"source_name_raw": "Salz", "source_name_normalized": "salz", "food_id": None, "food_name_de": None, "bls_code": None, "mapped": False},
]), "p")
assert rows[0]["mapped"] is True
assert rows[1]["mapped"] is False
def test_save_recipe_requires_name():
try:
save_recipe(None, "p", {"name_raw": " ", "ingredients": []})
except ValueError as e:
assert "Rezeptname" in str(e)
else:
raise AssertionError("expected ValueError")