feat: Stoffe nach BLS-Gruppen sortieren und aufklappbar listen
Energie und Makros zuerst, restliche Naehrstoffgruppen zuklappbar, damit die Liste bedienbar bleibt. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
94ddf84262
commit
44e3e216ab
6 files changed
+230
-95
No files matched your search
@@ -1,8 +1,11 @@
|
||||
from bls.attribute_labels import (
|
||||
annotate_attribute,
|
||||
apply_official_name,
|
||||
fill_placeholder_labels,
|
||||
label_is_placeholder,
|
||||
official_label,
|
||||
resolve_group,
|
||||
sort_attributes,
|
||||
)
|
||||
|
||||
|
||||
@@ -35,6 +38,20 @@ def test_fill_placeholder_labels_skips_custom_names():
|
||||
|
||||
cur = _Cur()
|
||||
stats = fill_placeholder_labels(cur)
|
||||
assert stats["updated"] == 1
|
||||
assert stats["updated"] == 2
|
||||
assert cur.updated[0][0] == "Fett"
|
||||
assert cur.updated[0][3] == 1
|
||||
assert cur.updated[1][0] == "Mein EPA"
|
||||
assert cur.updated[1][2] == "fatty_acids"
|
||||
|
||||
|
||||
def test_group_and_sort_macros_first():
|
||||
assert resolve_group("ENERCC")[0] == "energy"
|
||||
assert resolve_group("NA", None, None)[1] == "Mineralstoffe"
|
||||
assert resolve_group("XYZ", None, "extension")[0] == "extension"
|
||||
rows = sort_attributes([
|
||||
annotate_attribute({"attr_key": "NA", "name_de": "Natrium", "sort_order": 2, "origin": "official_bls"}),
|
||||
annotate_attribute({"attr_key": "FAT", "name_de": "Fett", "sort_order": 9, "origin": "official_bls"}),
|
||||
annotate_attribute({"attr_key": "ENERCC", "name_de": "Energie", "sort_order": 1, "origin": "official_bls"}),
|
||||
])
|
||||
assert [r["attr_key"] for r in rows] == ["ENERCC", "FAT", "NA"]
|
||||
Reference in new issue
Block a user