Mapping bleibt erhalten, auch wenn der Nährwert-Rebuild länger dauert. Offene Liste führt 1 ml/2 ml Olivenöl als ein Lebensmittel. Dazu JSON-Sicherung, eigener Katalogeintrag und Gramm-pro-Einheit. Co-authored-by: Cursor <cursoragent@cursor.com>
43 lines
1.1 KiB
Python
43 lines
1.1 KiB
Python
from data_layer.food_knowledge import (
|
|
BUNDLE_FORMAT,
|
|
parse_food_knowledge_bundle,
|
|
portable_mapping,
|
|
)
|
|
|
|
|
|
def test_parse_rejects_unknown_format():
|
|
try:
|
|
parse_food_knowledge_bundle({"format": "other", "version": 1})
|
|
except ValueError as e:
|
|
assert "Mitai-Zuordnungsdatei" in str(e)
|
|
else:
|
|
raise AssertionError("expected ValueError")
|
|
|
|
|
|
def test_parse_accepts_bundle():
|
|
data = parse_food_knowledge_bundle({
|
|
"format": BUNDLE_FORMAT,
|
|
"version": 1,
|
|
"mappings": [],
|
|
"recipes": [],
|
|
})
|
|
assert data["version"] == 1
|
|
|
|
|
|
def test_portable_mapping_drops_ids():
|
|
row = portable_mapping({
|
|
"id": 99,
|
|
"food_id": "uuid-here",
|
|
"source_system": "fddb",
|
|
"source_name_raw": "Haferflocken, Großblatt",
|
|
"source_name_normalized": "haferflocken großblatt",
|
|
"bls_code": "C131000",
|
|
"food_name_de": "Hafer roh",
|
|
"catalog_kind": "official_bls",
|
|
"external_key": None,
|
|
})
|
|
assert "id" not in row
|
|
assert "food_id" not in row
|
|
assert row["bls_code"] == "C131000"
|
|
assert row["source_name_raw"] == "Haferflocken, Großblatt"
|