feat: BLS-Stammdaten, FDDB-Mapping und Item-Tagebuch (#106)
Deploy Development / deploy (push) Failing after 52s
Build Test / pytest-backend (push) Successful in 3s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Failing after 9s

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>
This commit is contained in:
LarsandCursor committed 2026-09-12 14:35:57 +02:00
1 parent 72d101415f
commit 919c77fcf8
39 files changed
+2648 -47

No files matched your search

+39
View File
@@ -0,0 +1,39 @@
from io import BytesIO
from openpyxl import Workbook
from bls.parser import parse_components_xlsx, parse_foods_xlsx
def _xlsx(rows):
wb = Workbook()
ws = wb.active
for row in rows:
ws.append(row)
buf = BytesIO()
wb.save(buf)
return buf.getvalue()
def test_parse_components_dynamic():
data = _xlsx([
["Code", "Name_DE", "Name_EN", "Einheit"],
["ENERCC", "Energie", "Energy", "kcal/100g"],
["NA", "Natrium", "Sodium", "mg/100g"],
])
attrs = parse_components_xlsx(data)
keys = {a["attr_key"] for a in attrs}
assert "ENERCC" in keys
assert "NA" in keys
def test_parse_foods_keeps_bls_code():
data = _xlsx([
["BLS Code", "Name", "Food name", "ENERCC Energie [kcal/100g]", "ENERCC Herkunft", "ENERCC Referenz"],
["C131000", "Hafer roh", "Oats raw", 350, "Analyse", "MRI"],
])
parsed = parse_foods_xlsx(data)
assert parsed["foods"][0]["bls_code"] == "C131000"
assert parsed["foods"][0]["name_de"] == "Hafer roh"
vals = {v["attr_key"]: v["value_num"] for v in parsed["foods"][0]["values"]}
assert vals.get("ENERCC") == 350
+18
View File
@@ -0,0 +1,18 @@
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})