M8-R02: report DSMR MQTT source health
This commit is contained in:
@@ -46,6 +46,7 @@ def fake_mqtt(monkeypatch):
|
||||
monkeypatch.setattr("app.integrations.mqtt.mqtt_manager", fake)
|
||||
monkeypatch.setattr(dsmr_ingest, "_subscriptions", {})
|
||||
monkeypatch.setattr(dsmr_ingest, "_subscription_client_ids", {})
|
||||
monkeypatch.setattr(dsmr_ingest, "_subscription_tokens", {})
|
||||
monkeypatch.setattr(dsmr_ingest, "_tariffs", {})
|
||||
return fake
|
||||
|
||||
@@ -186,3 +187,17 @@ def test_same_snapshot_aba_rejects_retained_handler(fake_mqtt, monkeypatch):
|
||||
old_handler(b"stale") # type: ignore[operator]
|
||||
fake_mqtt.handlers[1]["same"](b"fresh") # type: ignore[operator]
|
||||
assert received == [(b"fresh", snapshot)]
|
||||
|
||||
|
||||
def test_source_state_handler_is_generation_scoped(fake_mqtt, monkeypatch):
|
||||
snapshot = _source(1, "same", broker_host="one.test")
|
||||
monkeypatch.setattr(dsmr_ingest, "_enabled_snapshots", lambda: [snapshot])
|
||||
dsmr_ingest.apply_dsmr_subscription()
|
||||
stale = fake_mqtt.replace_calls[-1][1]["state_handler"]
|
||||
monkeypatch.setattr(dsmr_ingest, "_enabled_snapshots", lambda: [])
|
||||
dsmr_ingest.apply_dsmr_subscription()
|
||||
monkeypatch.setattr(dsmr_ingest, "_enabled_snapshots", lambda: [snapshot])
|
||||
dsmr_ingest.apply_dsmr_subscription()
|
||||
|
||||
monkeypatch.setattr(dsmr_ingest, "get_session_local", lambda: (_ for _ in ()).throw(AssertionError()))
|
||||
stale("error") # type: ignore[operator]
|
||||
|
||||
Reference in New Issue
Block a user