feat: Eigene Stoffe am Lebensmittel anlegen
EPA-Chips und mg/µg vom Etikett; fehlende Parameter ohne Admin. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
a5adff6196
commit
d35087ad84
9 files changed
+246
-29
No files matched your search
@@ -1,4 +1,10 @@
|
||||
from data_layer.food_attributes import macros_and_attributes_to_values, scale_to_per_100g
|
||||
from data_layer.food_attributes import (
|
||||
create_extension_attribute,
|
||||
macros_and_attributes_to_values,
|
||||
normalize_attr_key,
|
||||
normalize_attr_unit,
|
||||
scale_to_per_100g,
|
||||
)
|
||||
|
||||
|
||||
def test_scale_serving_to_per_100g():
|
||||
@@ -7,6 +13,28 @@ def test_scale_serving_to_per_100g():
|
||||
assert scale_to_per_100g(10, None) == 10
|
||||
|
||||
|
||||
def test_attr_key_and_unit_normalize():
|
||||
assert normalize_attr_key("Vitamin D3") == "VITAMIN_D3"
|
||||
assert normalize_attr_unit("ug") == "µg"
|
||||
assert normalize_attr_unit("mcg") == "µg"
|
||||
|
||||
|
||||
def test_create_extension_returns_existing():
|
||||
class _Cur:
|
||||
def __init__(self):
|
||||
self.calls = 0
|
||||
|
||||
def execute(self, sql, params=None):
|
||||
self.calls += 1
|
||||
self._row = {"id": 1, "attr_key": "VITAMIN_D3", "name_de": "Vitamin D3", "name_en": None, "unit": "µg", "category": "extension", "origin": "extension"} if self.calls == 1 else None
|
||||
|
||||
def fetchone(self):
|
||||
return self._row
|
||||
|
||||
row = create_extension_attribute(_Cur(), "Vitamin D3", "µg")
|
||||
assert row["attr_key"] == "VITAMIN_D3"
|
||||
|
||||
|
||||
def test_norsan_label_epa_converts():
|
||||
"""Etikett: 1100 mg EPA = 1.1 g in 8 g Portion → g/100 g."""
|
||||
vals = macros_and_attributes_to_values(
|
||||
|
||||
Reference in new issue
Block a user