コード例 #1
0
ファイル: light_test.py プロジェクト: mielune/xknx
 def test_do(self):
     """Test 'do' functionality."""
     xknx = XKNX()
     light = Light(
         xknx,
         name="TestLight",
         group_address_switch="1/2/3",
         group_address_brightness="1/2/5",
         group_address_tunable_white="1/2/9",
         group_address_color_temperature="1/2/11",
     )
     self.loop.run_until_complete(light.do("on"))
     self.loop.run_until_complete(
         xknx.devices.process(xknx.telegrams.get_nowait()))
     self.assertTrue(light.state)
     self.loop.run_until_complete(light.do("brightness:80"))
     self.loop.run_until_complete(
         xknx.devices.process(xknx.telegrams.get_nowait()))
     self.assertEqual(light.current_brightness, 80)
     self.loop.run_until_complete(light.do("tunable_white:80"))
     self.loop.run_until_complete(
         xknx.devices.process(xknx.telegrams.get_nowait()))
     self.assertEqual(light.current_tunable_white, 80)
     self.loop.run_until_complete(light.do("color_temperature:3750"))
     self.loop.run_until_complete(
         xknx.devices.process(xknx.telegrams.get_nowait()))
     self.assertEqual(light.current_color_temperature, 3750)
     self.loop.run_until_complete(light.do("off"))
     self.loop.run_until_complete(
         xknx.devices.process(xknx.telegrams.get_nowait()))
     self.assertFalse(light.state)
コード例 #2
0
ファイル: light_test.py プロジェクト: qvistgaard/xknx
 def test_do(self):
     """Test 'do' functionality."""
     xknx = XKNX(loop=self.loop)
     light = Light(xknx,
                   name="TestLight",
                   group_address_switch='1/2/3',
                   group_address_brightness='1/2/5')
     self.loop.run_until_complete(asyncio.Task(light.do("on")))
     self.assertTrue(light.state)
     self.loop.run_until_complete(asyncio.Task(light.do("brightness:80")))
     self.assertEqual(light.brightness, 80)
     self.loop.run_until_complete(asyncio.Task(light.do("off")))
     self.assertFalse(light.state)
コード例 #3
0
 def test_do(self):
     """Test 'do' functionality."""
     xknx = XKNX(loop=self.loop)
     light = Light(xknx,
                   name="TestLight",
                   group_address_switch='1/2/3',
                   group_address_brightness='1/2/5',
                   group_address_tunable_white='1/2/9',
                   group_address_color_temperature='1/2/11')
     self.loop.run_until_complete(asyncio.Task(light.do("on")))
     self.assertTrue(light.state)
     self.loop.run_until_complete(asyncio.Task(light.do("brightness:80")))
     self.assertEqual(light.current_brightness, 80)
     self.loop.run_until_complete(asyncio.Task(light.do("tunable_white:80")))
     self.assertEqual(light.current_tunable_white, 80)
     self.loop.run_until_complete(asyncio.Task(light.do("color_temperature:3750")))
     self.assertEqual(light.current_color_temperature, 3750)
     self.loop.run_until_complete(asyncio.Task(light.do("off")))
     self.assertFalse(light.state)
コード例 #4
0
 def test_wrong_do(self):
     """Test wrong do command."""
     xknx = XKNX(loop=self.loop)
     light = Light(xknx,
                   name="TestLight",
                   group_address_switch='1/2/3',
                   group_address_brightness='1/2/5')
     with patch('logging.Logger.warning') as mock_warn:
         self.loop.run_until_complete(asyncio.Task(light.do("execute")))
         self.assertEqual(xknx.telegrams.qsize(), 0)
         mock_warn.assert_called_with('Could not understand action %s for device %s', 'execute', 'TestLight')
コード例 #5
0
ファイル: light_test.py プロジェクト: mielune/xknx
 def test_wrong_do(self):
     """Test wrong do command."""
     xknx = XKNX()
     light = Light(
         xknx,
         name="TestLight",
         group_address_switch="1/2/3",
         group_address_brightness="1/2/5",
     )
     with patch("logging.Logger.warning") as mock_warn:
         self.loop.run_until_complete(light.do("execute"))
         self.assertEqual(xknx.telegrams.qsize(), 0)
         mock_warn.assert_called_with(
             "Could not understand action %s for device %s", "execute",
             "TestLight")