Ejemplo n.º 1
0
 def test_unsigned_value_max_value(self):
     """Test DPT4ByteUnsigned parsing and streaming."""
     self.assertEqual(
         DPT4ByteUnsigned().to_knx(4294967295), (0xFF, 0xFF, 0xFF, 0xFF)
     )
     self.assertEqual(
         DPT4ByteUnsigned().from_knx((0xFF, 0xFF, 0xFF, 0xFF)), 4294967295
     )
Ejemplo n.º 2
0
 def test_unsigned_wrong_value_from_knx(self):
     """Test DPT4ByteUnsigned parsing with wrong value."""
     with pytest.raises(ConversionError):
         DPT4ByteUnsigned.from_knx((0xFF, 0x4E, 0x12))
Ejemplo n.º 3
0
 def test_unsigned_value_01234567(self):
     """Test DPT4ByteUnsigned parsing and streaming."""
     assert DPT4ByteUnsigned.to_knx(19088743) == (0x01, 0x23, 0x45, 0x67)
     assert DPT4ByteUnsigned.from_knx((0x01, 0x23, 0x45, 0x67)) == 19088743
Ejemplo n.º 4
0
 def test_unsigned_value_min_value(self):
     """Test parsing and streaming with null values."""
     assert DPT4ByteUnsigned.to_knx(0) == (0x00, 0x00, 0x00, 0x00)
     assert DPT4ByteUnsigned.from_knx((0x00, 0x00, 0x00, 0x00)) == 0
Ejemplo n.º 5
0
 def test_unsigned_value_max_value(self):
     """Test DPT4ByteUnsigned parsing and streaming."""
     assert DPT4ByteUnsigned.to_knx(4294967295) == (0xFF, 0xFF, 0xFF, 0xFF)
     assert DPT4ByteUnsigned.from_knx(
         (0xFF, 0xFF, 0xFF, 0xFF)) == 4294967295
Ejemplo n.º 6
0
 def test_unsigned_to_knx_exceed_limits(self):
     """Test initialization of DPT4ByteUnsigned with wrong value (Overflow)."""
     with pytest.raises(ConversionError):
         DPT4ByteUnsigned.to_knx(4294967296)
Ejemplo n.º 7
0
 def test_unsigned_assert_min_exceeded(self):
     """Test initialization of DPT4ByteUnsigned with wrong value (Underflow)."""
     with pytest.raises(ConversionError):
         DPT4ByteUnsigned.to_knx(-1)
Ejemplo n.º 8
0
 def test_unsigned_value_01234567(self):
     """Test DPT4ByteUnsigned parsing and streaming."""
     self.assertEqual(DPT4ByteUnsigned().to_knx(19088743),
                      (0x01, 0x23, 0x45, 0x67))
     self.assertEqual(DPT4ByteUnsigned().from_knx((0x01, 0x23, 0x45, 0x67)),
                      19088743)
Ejemplo n.º 9
0
 def test_unsigned_value_min_value(self):
     """Test parsing and streaming with null values."""
     self.assertEqual(DPT4ByteUnsigned().to_knx(0),
                      (0x00, 0x00, 0x00, 0x00))
     self.assertEqual(DPT4ByteUnsigned().from_knx((0x00, 0x00, 0x00, 0x00)),
                      0)
Ejemplo n.º 10
0
 def test_unsigned_settings(self):
     """Test members of DPT4ByteUnsigned."""
     self.assertEqual(DPT4ByteUnsigned().value_min, 0)
     self.assertEqual(DPT4ByteUnsigned().value_max, 4294967295)