Example #1
0
 def test_from_knx_unpack_error(self):
     """Test DPT4ByteSigned parsing with unpack error."""
     with patch("struct.unpack") as unpack_mock:
         unpack_mock.side_effect = struct.error()
         with pytest.raises(ConversionError):
             DPT4ByteSigned.from_knx((0x01, 0x23, 0x45, 0x67))
Example #2
0
 def test_signed_wrong_value_from_knx(self):
     """Test DPT4ByteSigned parsing with wrong value."""
     with pytest.raises(ConversionError):
         DPT4ByteSigned.from_knx((0xFF, 0x4E, 0x12))
Example #3
0
 def test_signed_value_min_value(self):
     """Test DPT4ByteSigned parsing and streaming with null values."""
     assert DPT4ByteSigned.to_knx(-2147483648) == (0x80, 0x00, 0x00, 0x00)
     assert DPT4ByteSigned.from_knx((0x80, 0x00, 0x00, 0x00)) == -2147483648
Example #4
0
 def test_signed_value_01234567(self):
     """Test DPT4ByteSigned parsing and streaming."""
     assert DPT4ByteSigned.to_knx(19088743) == (0x01, 0x23, 0x45, 0x67)
     assert DPT4ByteSigned.from_knx((0x01, 0x23, 0x45, 0x67)) == 19088743
Example #5
0
 def test_signed_value_max_value(self):
     """Test DPT4ByteSigned parsing and streaming."""
     assert DPT4ByteSigned.to_knx(2147483647) == (0x7F, 0xFF, 0xFF, 0xFF)
     assert DPT4ByteSigned.from_knx((0x7F, 0xFF, 0xFF, 0xFF)) == 2147483647