Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Uses threading to wait for daemon.run. Gentoo bug 934153
- # https://github.com/greenbone/ospd-openvas/pull/1026
- --- a/tests/messaging/test_mqtt.py
- +++ b/tests/messaging/test_mqtt.py
- @@ -3,6 +3,8 @@
- #
- # SPDX-License-Identifier: AGPL-3.0-or-later
- +import threading
- +
- from datetime import datetime
- from uuid import UUID
- @@ -88,10 +90,20 @@ class MQTTDaemonTestCase(TestCase):
- def test_run(self):
- client = mock.MagicMock()
- + start_event = threading.Event()
- +
- + def side_effect():
- + start_event.set()
- +
- + client.connect.side_effect = side_effect
- daemon = MQTTDaemon(client)
- - daemon.run()
- + run_thread = threading.Thread(target=daemon.run)
- + run_thread.start()
- +
- + # Wait for the daemon to start
- + start_event.wait()
- client.connect.assert_called_with()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement