Katalog, lernendes Mapping ohne KI, optionale Items und Import-Policy. Playwright-Smoke und Issue-Audit um Ernährung/Zuordnen/API ergänzt. Co-authored-by: Cursor <cursoragent@cursor.com>
19 lines
797 B
Python
19 lines
797 B
Python
from data_layer.food_mapping import normalize_food_name, parse_quantity_g
|
|
from data_layer.nutrition_items import macros_differ
|
|
|
|
|
|
def test_normalize_strips_leading_quantity():
|
|
assert normalize_food_name("50 g Hähnchen") == "hähnchen"
|
|
assert normalize_food_name(" Vollmilch 3,5% ") == "vollmilch 3.5%"
|
|
|
|
|
|
def test_parse_quantity_g():
|
|
assert parse_quantity_g("150 g") == 150.0
|
|
assert parse_quantity_g("150") == 150.0
|
|
assert parse_quantity_g("1 Stück") is None
|
|
|
|
|
|
def test_macros_differ_rounds():
|
|
assert not macros_differ({"kcal": 1.04, "protein_g": 0, "fat_g": 0, "carbs_g": 0}, {"kcal": 1.0, "protein_g": 0, "fat_g": 0, "carbs_g": 0})
|
|
assert macros_differ({"kcal": 10, "protein_g": 0, "fat_g": 0, "carbs_g": 0}, {"kcal": 11, "protein_g": 0, "fat_g": 0, "carbs_g": 0})
|