示例#1
0
 def test_to_knx_positive(self):
     """Test positive value to KNX."""
     self.assertEqual(DPTSignedRelativeValue.to_knx(0), (0x00, ))
     self.assertEqual(DPTSignedRelativeValue.to_knx(1), (0x01, ))
     self.assertEqual(DPTSignedRelativeValue.to_knx(2), (0x02, ))
     self.assertEqual(DPTSignedRelativeValue.to_knx(100), (0x64, ))
     self.assertEqual(DPTSignedRelativeValue.to_knx(127), (0x7F, ))
示例#2
0
 def test_assert_max_exceeded(self):
     """Test initialization with wrong value (Overflow)."""
     with self.assertRaises(ConversionError):
         DPTSignedRelativeValue.to_knx(128)
示例#3
0
 def test_to_knx_negative(self):
     """Test negative value to KNX."""
     self.assertEqual(DPTSignedRelativeValue.to_knx(-128), (0x80, ))
     self.assertEqual(DPTSignedRelativeValue.to_knx(-100), (0x9C, ))
     self.assertEqual(DPTSignedRelativeValue.to_knx(-2), (0xFE, ))
     self.assertEqual(DPTSignedRelativeValue.to_knx(-1), (0xFF, ))