Exemple #1
0
 def test_from_knx_wrong_parameter2(self):
     """Test parsing of DPTScaling with wrong value (array containing string)."""
     with self.assertRaises(ConversionError):
         DPTScaling().from_knx("0x23")
Exemple #2
0
 def test_from_knx_wrong_parameter(self):
     """Test parsing of DPTScaling with wrong value (3 byte array)."""
     with self.assertRaises(ConversionError):
         DPTScaling().from_knx((0x01, 0x02, 0x03))
Exemple #3
0
 def test_from_knx_wrong_value(self):
     """Test parsing of DPTScaling with value which exceeds limits."""
     with self.assertRaises(ConversionError):
         DPTScaling().from_knx((0x256, ))
Exemple #4
0
 def test_to_knx_max_exceeded(self):
     """Test parsing of DPTScaling with wrong value (overflow)."""
     with self.assertRaises(ConversionError):
         DPTScaling().to_knx(101)
Exemple #5
0
 def test_to_knx_wrong_parameter(self):
     """Test parsing of DPTScaling with wrong value (string)."""
     with self.assertRaises(ConversionError):
         DPTScaling().to_knx("fnord")
Exemple #6
0
 def test_value_max(self):
     """Test parsing and streaming of DPTScaling 100%."""
     self.assertEqual(DPTScaling().to_knx(100), (0xFF, ))
     self.assertEqual(DPTScaling().from_knx((0xFF, )), 100)
Exemple #7
0
 def test_value_min(self):
     """Test parsing and streaming of DPTScaling 0."""
     self.assertEqual(DPTScaling().to_knx(0), (0x00, ))
     self.assertEqual(DPTScaling().from_knx((0x00, )), 0)
Exemple #8
0
 def test_value_30_pct(self):
     """Test parsing and streaming of DPTScaling 30%."""
     self.assertEqual(DPTScaling().to_knx(30), (0x4C, ))
     self.assertEqual(DPTScaling().from_knx((0x4C, )), 30)
Exemple #9
0
 def test_value_99_pct(self):
     """Test parsing and streaming of DPTScaling 99%."""
     self.assertEqual(DPTScaling().to_knx(99), (0xFC, ))
     self.assertEqual(DPTScaling().from_knx((0xFC, )), 99)
Exemple #10
0
 def test_value_30_pct(self):
     """Test parsing and streaming of DPTScaling 30%."""
     assert DPTScaling.to_knx(30) == (0x4C, )
     assert DPTScaling.from_knx((0x4C, )) == 30
Exemple #11
0
 def test_to_knx_min_exceeded(self):
     """Test parsing of DPTScaling with wrong value (underflow)."""
     with pytest.raises(ConversionError):
         DPTScaling.to_knx(-1)
Exemple #12
0
 def test_value_min(self):
     """Test parsing and streaming of DPTScaling 0."""
     assert DPTScaling.to_knx(0) == (0x00, )
     assert DPTScaling.from_knx((0x00, )) == 0
Exemple #13
0
 def test_value_max(self):
     """Test parsing and streaming of DPTScaling 100%."""
     assert DPTScaling.to_knx(100) == (0xFF, )
     assert DPTScaling.from_knx((0xFF, )) == 100
Exemple #14
0
 def test_value_99_pct(self):
     """Test parsing and streaming of DPTScaling 99%."""
     assert DPTScaling.to_knx(99) == (0xFC, )
     assert DPTScaling.from_knx((0xFC, )) == 99