async def coro(): async with anyio.create_task_group() as tg: manager = PluginManager(tg, "hbmqtt.test.plugins", context=None) ret = await call_coro(manager) plugin = manager.get_plugin("event_plugin") self.assertEqual(ret[plugin], "TEST")
def test_map_coro_return(self): async def call_coro(): return await manager.map_plugin_coro("ret_coro") manager = PluginManager("hbmqtt.test.plugins", context=None, loop=self.loop) ret = self.loop.run_until_complete(call_coro()) plugin = manager.get_plugin("event_plugin") self.assertEqual(ret[plugin], "TEST")
async def coro(): async with anyio.create_task_group() as tg: manager = PluginManager(tg, "hbmqtt.test.plugins", context=None) await call_coro(manager) plugin = manager.get_plugin("event_plugin") self.assertTrue(plugin.object.test_coro)
def test_map_coro(self): async def call_coro(): await manager.map_plugin_coro("test_coro") manager = PluginManager("hbmqtt.test.plugins", context=None, loop=self.loop) self.loop.run_until_complete(call_coro()) plugin = manager.get_plugin("event_plugin") assert plugin.object.test_coro
def test_map_coro_return(self): @asyncio.coroutine def call_coro(): return (yield from manager.map_plugin_coro('ret_coro')) manager = PluginManager("hbmqtt.test.plugins", context=None, loop=self.loop) ret = self.loop.run_until_complete(call_coro()) plugin = manager.get_plugin("event_plugin") self.assertEqual(ret[plugin], "TEST")
def test_map_coro(self): @asyncio.coroutine def call_coro(): yield from manager.map_plugin_coro('test_coro') manager = PluginManager("hbmqtt.test.plugins", context=None, loop=self.loop) self.loop.run_until_complete(call_coro()) plugin = manager.get_plugin("event_plugin") self.assertTrue(plugin.object.test_coro)
def test_fire_event_wait(self): async def fire_event(): await manager.fire_event("test", wait=True) await manager.close() manager = PluginManager("hbmqtt.test.plugins", context=None, loop=self.loop) self.loop.run_until_complete(fire_event()) plugin = manager.get_plugin("event_plugin") assert plugin.object.test_flag
def test_fire_event_wait(self): @asyncio.coroutine def fire_event(): yield from manager.fire_event("test", wait=True) yield from manager.close() manager = PluginManager("hbmqtt.test.plugins", context=None, loop=self.loop) self.loop.run_until_complete(fire_event()) plugin = manager.get_plugin("event_plugin") self.assertTrue(plugin.object.test_flag)