mitai-jinkendo/backend/tests/test_widget_catalog.py

28 lines
1003 B
Python
Raw Normal View History

"""Widget-Katalog: Konsistenz (IDs, Default-Layout, Katalog-Response)."""
from dashboard_layout_schema import default_layout_dict
from widget_catalog import ALLOWED_WIDGET_IDS, DEFAULT_LAB_WIDGET_IDS, WIDGET_CATALOG, catalog_response
def test_catalog_ids_unique_and_match_allowed():
ids = [e["id"] for e in WIDGET_CATALOG]
assert len(ids) == len(set(ids))
assert frozenset(ids) == ALLOWED_WIDGET_IDS
def test_default_layout_follows_catalog_order():
d = default_layout_dict()
assert d["version"] == 1
got = [w["id"] for w in d["widgets"]]
assert got == [e["id"] for e in WIDGET_CATALOG]
enabled_ids = {w["id"] for w in d["widgets"] if w["enabled"]}
assert enabled_ids == DEFAULT_LAB_WIDGET_IDS
assert any(w["enabled"] for w in d["widgets"])
def test_catalog_response_shape():
r = catalog_response()
assert r["catalog_version"] == 1
assert len(r["widgets"]) == len(WIDGET_CATALOG)
assert {w["id"] for w in r["widgets"]} == ALLOWED_WIDGET_IDS