def test_from_knx_positive(self): """Test positive value from KNX.""" assert DPTSignedRelativeValue.from_knx((0x00,)) == 0 assert DPTSignedRelativeValue.from_knx((0x01,)) == 1 assert DPTSignedRelativeValue.from_knx((0x02,)) == 2 assert DPTSignedRelativeValue.from_knx((0x64,)) == 100 assert DPTSignedRelativeValue.from_knx((0x7F,)) == 127
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, ))
def test_to_knx_positive(self): """Test positive value to KNX.""" assert DPTSignedRelativeValue.to_knx(0) == (0x00,) assert DPTSignedRelativeValue.to_knx(1) == (0x01,) assert DPTSignedRelativeValue.to_knx(2) == (0x02,) assert DPTSignedRelativeValue.to_knx(100) == (0x64,) assert DPTSignedRelativeValue.to_knx(127) == (0x7F,)
def test_from_knx_positive(self): """Test positive value from KNX.""" self.assertEqual(DPTSignedRelativeValue.from_knx((0x00, )), 0) self.assertEqual(DPTSignedRelativeValue.from_knx((0x01, )), 1) self.assertEqual(DPTSignedRelativeValue.from_knx((0x02, )), 2) self.assertEqual(DPTSignedRelativeValue.from_knx((0x64, )), 100) self.assertEqual(DPTSignedRelativeValue.from_knx((0x7F, )), 127)
def test_assert_max_exceeded(self): """Test initialization with wrong value (Overflow).""" with pytest.raises(ConversionError): DPTSignedRelativeValue.to_knx(128)
def test_to_knx_negative(self): """Test negative value to KNX.""" assert DPTSignedRelativeValue.to_knx(-128) == (0x80,) assert DPTSignedRelativeValue.to_knx(-100) == (0x9C,) assert DPTSignedRelativeValue.to_knx(-2) == (0xFE,) assert DPTSignedRelativeValue.to_knx(-1) == (0xFF,)
def test_from_knx_negative(self): """Test negative value from KNX.""" assert DPTSignedRelativeValue.from_knx((0x80,)) == -128 assert DPTSignedRelativeValue.from_knx((0x9C,)) == -100 assert DPTSignedRelativeValue.from_knx((0xFE,)) == -2 assert DPTSignedRelativeValue.from_knx((0xFF,)) == -1
def test_assert_min_exceeded(self): """Test initialization with wrong value (Underflow).""" with self.assertRaises(ConversionError): DPTSignedRelativeValue.to_knx(-129)
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, ))
def test_from_knx_negative(self): """Test negative value from KNX.""" self.assertEqual(DPTSignedRelativeValue.from_knx((0x80, )), -128) self.assertEqual(DPTSignedRelativeValue.from_knx((0x9C, )), -100) self.assertEqual(DPTSignedRelativeValue.from_knx((0xFE, )), -2) self.assertEqual(DPTSignedRelativeValue.from_knx((0xFF, )), -1)