Ejemplo n.º 1
0
 def test_do(self):
     """Test 'do' functionality."""
     xknx = XKNX(loop=self.loop)
     switch = Switch(xknx, 'TestOutlet', group_address='1/2/3')
     self.loop.run_until_complete(asyncio.Task(switch.do("on")))
     self.assertTrue(switch.state)
     self.loop.run_until_complete(asyncio.Task(switch.do("off")))
     self.assertFalse(switch.state)
Ejemplo n.º 2
0
 def test_do(self):
     """Test 'do' functionality."""
     xknx = XKNX(loop=self.loop)
     switch = Switch(xknx, 'TestOutlet', group_address='1/2/3')
     self.loop.run_until_complete(asyncio.Task(switch.do("on")))
     self.assertTrue(switch.state)
     self.loop.run_until_complete(asyncio.Task(switch.do("off")))
     self.assertFalse(switch.state)
Ejemplo n.º 3
0
 def test_do(self):
     """Test 'do' functionality."""
     xknx = XKNX()
     switch = Switch(xknx, "TestOutlet", group_address="1/2/3")
     self.loop.run_until_complete(switch.do("on"))
     self.loop.run_until_complete(xknx.devices.process(xknx.telegrams.get_nowait()))
     self.assertTrue(switch.state)
     self.loop.run_until_complete(switch.do("off"))
     self.loop.run_until_complete(xknx.devices.process(xknx.telegrams.get_nowait()))
     self.assertFalse(switch.state)
Ejemplo n.º 4
0
 def test_wrong_do(self):
     """Test wrong do command."""
     xknx = XKNX(loop=self.loop)
     switch = Switch(xknx, 'TestOutlet', group_address='1/2/3')
     with patch('logging.Logger.warning') as mock_warn:
         self.loop.run_until_complete(asyncio.Task(switch.do("execute")))
         mock_warn.assert_called_with('Could not understand action %s for device %s', 'execute', 'TestOutlet')
     self.assertEqual(xknx.telegrams.qsize(), 0)
Ejemplo n.º 5
0
 def test_wrong_do(self):
     """Test wrong do command."""
     xknx = XKNX(loop=self.loop)
     switch = Switch(xknx, 'TestOutlet', group_address='1/2/3')
     with patch('logging.Logger.warning') as mock_warn:
         self.loop.run_until_complete(asyncio.Task(switch.do("execute")))
         mock_warn.assert_called_with('Could not understand action %s for device %s', 'execute', 'TestOutlet')
     self.assertEqual(xknx.telegrams.qsize(), 0)
Ejemplo n.º 6
0
 def test_wrong_do(self):
     """Test wrong do command."""
     xknx = XKNX()
     switch = Switch(xknx, "TestOutlet", group_address="1/2/3")
     with patch("logging.Logger.warning") as mock_warn:
         self.loop.run_until_complete(switch.do("execute"))
         mock_warn.assert_called_with(
             "Could not understand action %s for device %s", "execute", "TestOutlet"
         )
     self.assertEqual(xknx.telegrams.qsize(), 0)