Show last error status on integrations. Closes #122.

This commit is contained in:
Jack Kingsman
2026-03-29 18:47:17 -07:00
parent 20532f70a3
commit 08d55dec72
16 changed files with 290 additions and 31 deletions
+29
View File
@@ -271,6 +271,35 @@ class TestFanoutManagerDispatch:
assert statuses["test-id"]["name"] == "Test"
assert statuses["test-id"]["type"] == "mqtt_private"
def test_get_statuses_includes_last_error(self):
manager = FanoutManager()
mod = StubModule()
mod._status = "error"
mod._last_error = "HTTP 500"
manager._modules["test-id"] = (mod, {})
with patch(
"app.repository.fanout._configs_cache",
{"test-id": {"name": "Test", "type": "webhook", "enabled": True}},
):
statuses = manager.get_statuses()
assert statuses["test-id"]["status"] == "error"
assert statuses["test-id"]["last_error"] == "HTTP 500"
def test_get_statuses_includes_start_failure_error(self):
manager = FanoutManager()
manager._module_errors["test-id"] = "ConnectionError: broker down"
with patch(
"app.repository.fanout._configs_cache",
{"test-id": {"name": "Test", "type": "mqtt_private", "enabled": True}},
):
statuses = manager.get_statuses()
assert statuses["test-id"]["status"] == "error"
assert statuses["test-id"]["last_error"] == "ConnectionError: broker down"
# ---------------------------------------------------------------------------
# Repository tests
+8 -2
View File
@@ -28,11 +28,17 @@ class TestHealthFanoutStatus:
async def test_fanout_statuses_reflect_manager(self, test_db):
"""fanout_statuses should return whatever the manager reports."""
mock_statuses = {
"uuid-1": {"name": "Private MQTT", "type": "mqtt_private", "status": "connected"},
"uuid-1": {
"name": "Private MQTT",
"type": "mqtt_private",
"status": "connected",
"last_error": None,
},
"uuid-2": {
"name": "Community MQTT",
"type": "mqtt_community",
"status": "disconnected",
"status": "error",
"last_error": "auth failed",
},
}
with patch("app.fanout.manager.fanout_manager") as mock_fm:
+1
View File
@@ -146,6 +146,7 @@ class TestMqttPublisher:
# After a publish failure, connected should be cleared to stop
# further attempts and reflect accurate status
assert pub.connected is False
assert pub.last_error == "Network error"
assert "Primary MQTT" in caplog.text
assert "usually transient network noise" in caplog.text