Tagebuchzeilen eigener Rezepte werden über den Listen-Import in Zutaten zerlegt. Zuordnen erfolgt im Namens-Popup statt per BLS-Code. Co-authored-by: Cursor <cursoragent@cursor.com>
44 lines
1.6 KiB
Python
44 lines
1.6 KiB
Python
from bls.recipe_parser import parse_fddb_lists_csv, parse_fddb_produkte
|
|
from data_layer.food_mapping import normalize_food_name
|
|
|
|
|
|
PORRIDGE = (
|
|
"160 g Apfel, Braeburn, 5 ml Omega-3 Vegan Algenöl, 100 g Wildheidelbeeren, "
|
|
"30 g Haferflocken, 100% Hafer-Vollkorn, 40 g Hafer Flocken, Großblatt, 11 g Flohsamenschalen"
|
|
)
|
|
|
|
|
|
def test_parse_fddb_produkte_splits_on_next_quantity_not_commas():
|
|
ings = parse_fddb_produkte(PORRIDGE)
|
|
names = [i["source_name_raw"] for i in ings]
|
|
assert names == [
|
|
"Apfel, Braeburn",
|
|
"Omega-3 Vegan Algenöl",
|
|
"Wildheidelbeeren",
|
|
"Haferflocken, 100% Hafer-Vollkorn",
|
|
"Hafer Flocken, Großblatt",
|
|
"Flohsamenschalen",
|
|
]
|
|
assert ings[0]["quantity_g"] == 160.0
|
|
assert ings[1]["quantity_g"] == 5.0
|
|
assert ings[1]["quantity_raw"] == "5 ml"
|
|
|
|
|
|
def test_parse_fddb_lists_csv_porridge_and_portions():
|
|
text = (
|
|
"name;beschreibung;anzahl_portionen;zeit_vorbereitung;zeit_kochen;produkte;\n"
|
|
'"!PorridgeBreakfast ";"";"1";"0";"0";"' + PORRIDGE + '";\n'
|
|
'"Aloo gobi";"";"4";"0";"0";"32 ml Rapso Rapsöl, 83 g Zwiebel, frisch";\n'
|
|
)
|
|
recipes = parse_fddb_lists_csv(text)
|
|
assert len(recipes) == 2
|
|
assert recipes[0]["name_raw"] == "!PorridgeBreakfast"
|
|
assert recipes[0]["name_normalized"] == normalize_food_name("PorridgeBreakfast")
|
|
assert len(recipes[0]["ingredients"]) == 6
|
|
assert recipes[1]["portions"] == 4.0
|
|
assert recipes[1]["ingredients"][0]["source_name_raw"] == "Rapso Rapsöl"
|
|
|
|
|
|
def test_normalize_strips_list_bang_prefix():
|
|
assert normalize_food_name("!PorridgeBreakfast") == normalize_food_name("PorridgeBreakfast")
|