mitai-jinkendo/backend/tests/test_reference_values_data_layer.py
Lars 932bceb1e1
All checks were successful
Deploy Development / deploy (push) Successful in 47s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 23s
feat: Update reference values and introduce pilot visualization module
- Bumped version of reference_values module to 1.3.0.
- Added new imports and functionality for reference values in the backend, enhancing data retrieval.
- Introduced a new PilotVizPage in the frontend for visualizing data, linked from the SettingsPage for easy access.
- Updated routing in App.jsx to include the new pilot visualization route.
2026-04-07 10:15:13 +02:00

49 lines
1.6 KiB
Python

"""Unit tests for data_layer.reference_values (summary assembly, no DB)."""
from data_layer.reference_values import build_summary_tiles_from_ranked_rows
def test_build_summary_tiles_single_type_two_rows():
raw = [
{
"type_key": "hr_max",
"type_label": "HF max",
"type_sort_order": 1,
"value_data_type": "decimal",
"rn": 1,
"id": 2,
"effective_date": "2026-04-01",
"value_numeric": 180.0,
"value_text": None,
"unit": "bpm",
},
{
"type_key": "hr_max",
"type_label": "HF max",
"type_sort_order": 1,
"value_data_type": "decimal",
"rn": 2,
"id": 1,
"effective_date": "2026-03-01",
"value_numeric": 175.0,
"value_text": None,
"unit": "bpm",
},
]
tiles = build_summary_tiles_from_ranked_rows(raw)
assert len(tiles) == 1
t = tiles[0]
assert t["type_key"] == "hr_max"
assert t["latest"]["value_numeric"] == 180.0
assert t["previous"]["value_numeric"] == 175.0
assert "sort_key" not in t
def test_build_summary_tiles_multi_type_order():
raw = [
{"type_key": "b", "type_label": "B", "type_sort_order": 2, "value_data_type": "decimal", "rn": 1, "id": 1},
{"type_key": "a", "type_label": "A", "type_sort_order": 1, "value_data_type": "decimal", "rn": 1, "id": 2},
]
tiles = build_summary_tiles_from_ranked_rows(raw)
assert [x["type_key"] for x in tiles] == ["a", "b"]