Пример #1
0
 def test_value_50(self):
     """Test parsing and streaming of DPTValue1Ucount 50."""
     assert DPTValue1Ucount.to_knx(50) == (0x32,)
     assert DPTValue1Ucount.from_knx((0x32,)) == 50
 def from_knx(self, payload: DPTArray) -> int:
     """Convert current payload to value."""
     return DPTValue1Ucount.from_knx(payload.value)
Пример #3
0
 def test_from_knx_wrong_parameter2(self):
     """Test parsing of DPTValue1Ucount with wrong value (array containing string)."""
     with pytest.raises(ConversionError):
         DPTValue1Ucount.from_knx("0x23")
Пример #4
0
 def test_from_knx_wrong_value(self):
     """Test parsing of DPTValue1Ucount with value which exceeds limits."""
     with pytest.raises(ConversionError):
         DPTValue1Ucount.from_knx((0x256,))
Пример #5
0
 def test_from_knx_wrong_parameter(self):
     """Test parsing of DPTValue1Ucount with wrong value (3 byte array)."""
     with pytest.raises(ConversionError):
         DPTValue1Ucount.from_knx((0x01, 0x02, 0x03))
Пример #6
0
 def test_value_min(self):
     """Test parsing and streaming of DPTValue1Ucount 0."""
     assert DPTValue1Ucount.to_knx(0) == (0x00,)
     assert DPTValue1Ucount.from_knx((0x00,)) == 0
Пример #7
0
 def test_value_max(self):
     """Test parsing and streaming of DPTValue1Ucount 255."""
     assert DPTValue1Ucount.to_knx(255) == (0xFF,)
     assert DPTValue1Ucount.from_knx((0xFF,)) == 255