From 44de3ca06b8d46287d7d41af6c432f96570204a2 Mon Sep 17 00:00:00 2001 From: Daniel McKnight Date: Tue, 21 Jan 2025 12:40:43 -0800 Subject: [PATCH] Update test to wait for open event --- tests/test_connector.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/test_connector.py b/tests/test_connector.py index 1d2993f..9102924 100644 --- a/tests/test_connector.py +++ b/tests/test_connector.py @@ -367,8 +367,9 @@ def test_emit_mq_message(self): queue=test_queue, callback=callback) connector.run(run_sync=False, run_observer=False) + open_event = threading.Event() close_event = threading.Event() - on_open = Mock() + on_open = Mock(side_effect=lambda *args: open_event.set()) on_error = Mock() on_close = Mock(side_effect=lambda *args: close_event.set()) @@ -396,6 +397,8 @@ def test_emit_mq_message(self): callback_event.clear() # Async connection emit + open_event.wait(timeout=5) + self.assertTrue(open_event.is_set()) on_open.assert_called_once() message_id_2 = connector.emit_mq_message(async_connection, request_data, queue=test_queue)