X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FMON.git;a=blobdiff_plain;f=osm_mon%2Ftests%2Funit%2Fcore%2Ftest_message_bus_client.py;fp=osm_mon%2Ftests%2Funit%2Fcore%2Ftest_message_bus_client.py;h=b35c6c13f376ce2300be6322d3a5fcb14aa40c73;hp=126eb9f73558346b5fe0b437e7a77f35d0f644b8;hb=072b0bdeb1a0919c5cc8de128fa3c62e8393ed7c;hpb=ca2fd226036f433ba97c427fbfdb08e2a339ab08 diff --git a/osm_mon/tests/unit/core/test_message_bus_client.py b/osm_mon/tests/unit/core/test_message_bus_client.py index 126eb9f..b35c6c1 100644 --- a/osm_mon/tests/unit/core/test_message_bus_client.py +++ b/osm_mon/tests/unit/core/test_message_bus_client.py @@ -34,39 +34,38 @@ class TestMessageBusClient(TestCase): def setUp(self): self.config = Config() self.config.set("message", "driver", "kafka") - self.loop = asyncio.new_event_loop() @mock.patch.object(MsgKafka, "aioread") def test_aioread(self, aioread): async def mock_callback(): pass - future = asyncio.Future(loop=self.loop) + future = asyncio.Future(loop=asyncio.new_event_loop()) future.set_result("mock") aioread.return_value = future - msg_bus = MessageBusClient(self.config, loop=self.loop) + msg_bus = MessageBusClient(self.config) topic = "test_topic" - self.loop.run_until_complete(msg_bus.aioread([topic], mock_callback)) - aioread.assert_called_with(["test_topic"], self.loop, aiocallback=mock_callback) + asyncio.run(msg_bus.aioread([topic], mock_callback)) + aioread.assert_called_with(["test_topic"], aiocallback=mock_callback) @mock.patch.object(MsgKafka, "aiowrite") def test_aiowrite(self, aiowrite): - future = asyncio.Future(loop=self.loop) + future = asyncio.Future(loop=asyncio.new_event_loop()) future.set_result("mock") aiowrite.return_value = future - msg_bus = MessageBusClient(self.config, loop=self.loop) + msg_bus = MessageBusClient(self.config) topic = "test_topic" key = "test_key" msg = {"test": "test_msg"} - self.loop.run_until_complete(msg_bus.aiowrite(topic, key, msg)) - aiowrite.assert_called_with(topic, key, msg, self.loop) + asyncio.run(msg_bus.aiowrite(topic, key, msg)) + aiowrite.assert_called_with(topic, key, msg) @mock.patch.object(MsgKafka, "aioread") def test_aioread_once(self, aioread): - future = asyncio.Future(loop=self.loop) + future = asyncio.Future(loop=asyncio.new_event_loop()) future.set_result("mock") aioread.return_value = future - msg_bus = MessageBusClient(self.config, loop=self.loop) + msg_bus = MessageBusClient(self.config) topic = "test_topic" - self.loop.run_until_complete(msg_bus.aioread_once(topic)) - aioread.assert_called_with("test_topic", self.loop) + asyncio.run(msg_bus.aioread_once(topic)) + aioread.assert_called_with("test_topic")