mirror of
https://github.com/jkingsman/Remote-Terminal-for-MeshCore.git
synced 2026-08-08 09:43:03 +02:00
Show last error status on integrations. Closes #122.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user