コード例 #1
0
 def test_to_knx_error(self):
     """Test to_knx function with wrong parametern."""
     xknx = XKNX(loop=self.loop)
     remote_value = RemoteValueSceneNumber(xknx)
     with self.assertRaises(ConversionError):
         remote_value.to_knx(100)
     with self.assertRaises(ConversionError):
         remote_value.to_knx("100")
コード例 #2
0
 def test_process(self):
     """Test process telegram."""
     xknx = XKNX(loop=self.loop)
     remote_value = RemoteValueSceneNumber(
         xknx, group_address=GroupAddress("1/2/3"))
     telegram = Telegram(group_address=GroupAddress("1/2/3"),
                         payload=DPTArray((0x0A, )))
     self.loop.run_until_complete(
         asyncio.Task(remote_value.process(telegram)))
     self.assertEqual(remote_value.value, 10)
コード例 #3
0
 def test_process(self):
     """Test process telegram."""
     xknx = XKNX(loop=self.loop)
     remote_value = RemoteValueSceneNumber(
         xknx,
         group_address=GroupAddress("1/2/3"))
     telegram = Telegram(
         group_address=GroupAddress("1/2/3"),
         payload=DPTArray((0x0A, )))
     self.loop.run_until_complete(asyncio.Task(remote_value.process(telegram)))
     self.assertEqual(remote_value.value, 11)
コード例 #4
0
 def test_to_process_error(self):
     """Test process errornous telegram."""
     xknx = XKNX(loop=self.loop)
     remote_value = RemoteValueSceneNumber(
         xknx,
         group_address=GroupAddress("1/2/3"))
     with self.assertRaises(CouldNotParseTelegram):
         telegram = Telegram(
             group_address=GroupAddress("1/2/3"),
             payload=DPTBinary(1))
         self.loop.run_until_complete(asyncio.Task(remote_value.process(telegram)))
     with self.assertRaises(CouldNotParseTelegram):
         telegram = Telegram(
             group_address=GroupAddress("1/2/3"),
             payload=DPTArray((0x64, 0x65, )))
         self.loop.run_until_complete(asyncio.Task(remote_value.process(telegram)))
コード例 #5
0
 def test_to_process_error(self):
     """Test process errornous telegram."""
     xknx = XKNX(loop=self.loop)
     remote_value = RemoteValueSceneNumber(
         xknx,
         group_address=GroupAddress("1/2/3"))
     with self.assertRaises(CouldNotParseTelegram):
         telegram = Telegram(
             group_address=GroupAddress("1/2/3"),
             payload=DPTBinary(1))
         self.loop.run_until_complete(asyncio.Task(remote_value.process(telegram)))
     with self.assertRaises(CouldNotParseTelegram):
         telegram = Telegram(
             group_address=GroupAddress("1/2/3"),
             payload=DPTArray((0x64, 0x65, )))
         self.loop.run_until_complete(asyncio.Task(remote_value.process(telegram)))
コード例 #6
0
 def test_set(self):
     """Test setting value."""
     xknx = XKNX(loop=self.loop)
     remote_value = RemoteValueSceneNumber(
         xknx, group_address=GroupAddress("1/2/3"))
     self.loop.run_until_complete(asyncio.Task(remote_value.set(10)))
     self.assertEqual(xknx.telegrams.qsize(), 1)
     telegram = xknx.telegrams.get_nowait()
     self.assertEqual(
         telegram,
         Telegram(GroupAddress('1/2/3'), payload=DPTArray((0x0A, ))))
     self.loop.run_until_complete(asyncio.Task(remote_value.set(11)))
     self.assertEqual(xknx.telegrams.qsize(), 1)
     telegram = xknx.telegrams.get_nowait()
     self.assertEqual(
         telegram,
         Telegram(GroupAddress('1/2/3'), payload=DPTArray((0x0B, ))))
コード例 #7
0
 def test_set(self):
     """Test setting value."""
     xknx = XKNX(loop=self.loop)
     remote_value = RemoteValueSceneNumber(
         xknx,
         group_address=GroupAddress("1/2/3"))
     self.loop.run_until_complete(asyncio.Task(remote_value.set(11)))
     self.assertEqual(xknx.telegrams.qsize(), 1)
     telegram = xknx.telegrams.get_nowait()
     self.assertEqual(
         telegram,
         Telegram(
             GroupAddress('1/2/3'),
             payload=DPTArray((0x0A, ))))
     self.loop.run_until_complete(asyncio.Task(remote_value.set(12)))
     self.assertEqual(xknx.telegrams.qsize(), 1)
     telegram = xknx.telegrams.get_nowait()
     self.assertEqual(
         telegram,
         Telegram(
             GroupAddress('1/2/3'),
             payload=DPTArray((0x0B, ))))
コード例 #8
0
 def test_to_knx_error(self):
     """Test to_knx function with wrong parametern."""
     xknx = XKNX(loop=self.loop)
     remote_value = RemoteValueSceneNumber(xknx)
     with self.assertRaises(ConversionError):
         remote_value.to_knx(100)
     with self.assertRaises(ConversionError):
         remote_value.to_knx("100")
コード例 #9
0
 def test_from_knx(self):
     """Test from_knx function with normal operation."""
     xknx = XKNX(loop=self.loop)
     remote_value = RemoteValueSceneNumber(xknx)
     self.assertEqual(remote_value.from_knx(DPTArray((0x0A, ))), 10)
コード例 #10
0
 def test_from_knx(self):
     """Test from_knx function with normal operation."""
     xknx = XKNX(loop=self.loop)
     remote_value = RemoteValueSceneNumber(xknx)
     self.assertEqual(remote_value.from_knx(DPTArray((0x0A, ))), 11)