def test_execute_unknown_device(self): """Test if execute method of Action calls correct do method of device.""" xknx = XKNX(loop=self.loop) action = Action(xknx, target='Light1', method='on') with patch('logging.Logger.warning') as logger_warning_mock: self.loop.run_until_complete(asyncio.Task(action.execute())) logger_warning_mock.assert_called_once_with( "Unknown device %s witin action %s.", action.target, action)
def test_execute_action(self): """Test if execute method of Action calls correct do method of device.""" xknx = XKNX(loop=self.loop) light = Light(xknx, "Light1", group_address_switch="1/6/4") action = Action(xknx, target=light.name, method="on") with patch("xknx.devices.Light.do") as mock_do: fut = asyncio.Future() fut.set_result(None) mock_do.return_value = fut self.loop.run_until_complete(action.execute()) mock_do.assert_called_with("on")
def test_execute_action(self): """Test if execute method of Action calls correct do method of device.""" xknx = XKNX(loop=self.loop) light = Light(xknx, 'Light1', group_address_switch='1/6/4') xknx.devices.add(light) action = Action(xknx, target='Light1', method='on') with patch('xknx.devices.Light.do') as mock_do: fut = asyncio.Future() fut.set_result(None) mock_do.return_value = fut self.loop.run_until_complete(asyncio.Task(action.execute())) mock_do.assert_called_with('on')
def test_execute_action(self): """Test if execute method of Action calls correct do method of device.""" xknx = XKNX(loop=self.loop) light = Light( xknx, 'Light1', group_address_switch='1/6/4') xknx.devices.add(light) action = Action(xknx, target='Light1', method='on') with patch('xknx.devices.Light.do') as mock_do: fut = asyncio.Future() fut.set_result(None) mock_do.return_value = fut self.loop.run_until_complete(asyncio.Task(action.execute())) mock_do.assert_called_with('on')