def test_process_callback(self): """Test process / reading telegrams from telegram queue. Test if callback was called.""" # pylint: disable=no-self-use xknx = XKNX() switch = Switch(xknx, "TestOutlet", group_address="1/2/3") after_update_callback = Mock() async def async_after_update_callback(device): """Async callback.""" after_update_callback(device) switch.register_device_updated_cb(async_after_update_callback) telegram = Telegram(group_address=GroupAddress("1/2/3"), payload=DPTBinary(1)) self.loop.run_until_complete(switch.process(telegram)) after_update_callback.assert_called_with(switch)
def test_process_callback(self): """Test process / reading telegrams from telegram queue. Test if callback was called.""" # pylint: disable=no-self-use xknx = XKNX(loop=self.loop) switch = Switch(xknx, 'TestOutlet', group_address='1/2/3') after_update_callback = Mock() async def async_after_update_callback(device): """Async callback.""" after_update_callback(device) switch.register_device_updated_cb(async_after_update_callback) telegram = Telegram() telegram.group_address = GroupAddress('1/2/3') telegram.payload = DPTBinary(1) self.loop.run_until_complete(asyncio.Task(switch.process(telegram))) after_update_callback.assert_called_with(switch)
async def test_process_callback(self): """Test process / reading telegrams from telegram queue. Test if callback was called.""" xknx = XKNX() switch = Switch(xknx, "TestOutlet", group_address="1/2/3") after_update_callback = Mock() async def async_after_update_callback(device): """Async callback.""" after_update_callback(device) switch.register_device_updated_cb(async_after_update_callback) telegram = Telegram( destination_address=GroupAddress("1/2/3"), payload=GroupValueWrite(DPTBinary(1)), ) await switch.process(telegram) after_update_callback.assert_called_with(switch)
def test_process_callback(self): """Test process / reading telegrams from telegram queue. Test if callback was called.""" # pylint: disable=no-self-use xknx = XKNX(loop=self.loop) switch = Switch(xknx, 'TestOutlet', group_address='1/2/3') after_update_callback = Mock() @asyncio.coroutine def async_after_update_callback(device): """Async callback.""" after_update_callback(device) switch.register_device_updated_cb(async_after_update_callback) telegram = Telegram() telegram.group_address = Address('1/2/3') telegram.payload = DPTBinary(1) self.loop.run_until_complete(asyncio.Task(switch.process(telegram))) after_update_callback.assert_called_with(switch)