Add pump profile fetching and Insulineprofiel page
willemjan/glucose-dashboard/pipeline/head This commit looks good

Fetch and parse the latest-used Nightscout profile (basal schedule, ISF,
carb ratio, DIA, targets) and show it as a new dashboard page: a list of
basal/ISF/carb-ratio segments plus a bar chart of basal rate by hour of
day. This is the data foundation for treatment overlays on the glucose
charts and the redesigned PDF report in follow-up PRs.
This commit is contained in:
2026-09-05 21:37:17 +02:00
parent 8641022219
commit 79249958c2
6 changed files with 423 additions and 1 deletions
+23
View File
@@ -357,6 +357,29 @@ def test_fetch_treatments_range_retrieves_full_history_even_with_a_hidden_server
assert result["timestamp"].max().date() == end_date
def test_fetch_profile_returns_first_document(monkeypatch):
monkeypatch.setenv("NIGHTSCOUT_URL", "https://example.com")
payload = [{"defaultProfile": "Default", "store": {"Default": {"dia": "5"}}}]
seen_params = []
monkeypatch.setattr(
ns.requests,
"get",
lambda *a, **k: (seen_params.append(k["params"]), FakeResponse(payload))[1],
)
result = ns.fetch_profile()
assert result == payload[0]
assert seen_params[0]["count"] == 1
def test_fetch_profile_handles_empty_response(monkeypatch):
monkeypatch.setenv("NIGHTSCOUT_URL", "https://example.com")
monkeypatch.setattr(ns.requests, "get", lambda *a, **k: FakeResponse([]))
assert ns.fetch_profile() == {}
def test_paginated_get_uses_created_at_field_for_treatments_cursor(monkeypatch):
"""Losstaande, gerichte assertie op het daadwerkelijke queryparameter-veld
— moet `find[created_at][$lte]` zijn, nooit `find[date][$lte]`, voor het