From f968bcc540c22dad89a2ee3bdfc6384b97b6fa0f Mon Sep 17 00:00:00 2001 From: Juan Jose Nicola Date: Mon, 31 Mar 2025 14:04:45 -0300 Subject: [PATCH] Fix: mqtt test --- tests/messaging/test_mqtt.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/messaging/test_mqtt.py b/tests/messaging/test_mqtt.py index 5b00518d..1034a89f 100644 --- a/tests/messaging/test_mqtt.py +++ b/tests/messaging/test_mqtt.py @@ -3,6 +3,7 @@ # # SPDX-License-Identifier: AGPL-3.0-or-later +import time from datetime import datetime from uuid import UUID @@ -87,12 +88,15 @@ def test_connect(self): daemon = MQTTDaemon(client) def test_run(self): - client = mock.MagicMock() - + client = mock.MagicMock(side_effect=1) daemon = MQTTDaemon(client) + t_ini = time.time() daemon.run() + # In some systems the spawn of the thread can take longer than expected. + # Therefore, we wait until the thread is spawned or times out. + while len(client.mock_calls) == 0 and time.time() - t_ini < 10: + time.sleep(1) client.connect.assert_called_with() - client.loop_start.assert_called_with()