Beispiel #1
0
 def test_to_knx_wrong_values(self):
     """Test serializing map with keys of invalid values to DPTControlStepCode."""
     # with self.assertRaises(ConversionError):
     #     DPTControlStepCode.to_knx({"control": -1, "step_code": 0})
     # with self.assertRaises(ConversionError):
     #     DPTControlStepCode.to_knx({"control": 2, "step_code": 0})
     with pytest.raises(ConversionError):
         DPTControlStepCode.to_knx({"control": 0, "step_code": -1})
     with pytest.raises(ConversionError):
         DPTControlStepCode.to_knx({"control": 0, "step_code": 0x8})
Beispiel #2
0
 def test_to_knx(self):
     """Test serializing values to DPTControlStepCode."""
     for rawref in range(16):
         control = 1 if rawref >> 3 else 0
         raw = DPTControlStepCode.to_knx(
             {"control": control, "step_code": rawref & 0x07}
         )
         assert raw == (rawref,)
Beispiel #3
0
 def test_to_knx_inverted(self):
     """Test serializing values to DPTControlStepCode in inverted mode."""
     for rawref in range(16):
         control = 0 if rawref >> 3 else 1
         raw = DPTControlStepCode.to_knx(
             {
                 "control": control,
                 "step_code": rawref & 0x07
             }, invert=True)
         self.assertEqual(raw, rawref)
Beispiel #4
0
 def test_to_knx_wrong_value_types(self):
     """Test serializing map with keys of invalid type to DPTControlStepCode."""
     with pytest.raises(ConversionError):
         DPTControlStepCode.to_knx({"control": ""})
     with pytest.raises(ConversionError):
         DPTControlStepCode.to_knx({"step_code": ""})
Beispiel #5
0
 def test_to_knx_wrong_keys(self):
     """Test serializing map with missing keys to DPTControlStepCode."""
     with pytest.raises(ConversionError):
         DPTControlStepCode.to_knx({"control": 0})
     with pytest.raises(ConversionError):
         DPTControlStepCode.to_knx({"step_code": 0})
Beispiel #6
0
 def test_to_knx_wrong_type(self):
     """Test serializing wrong type to DPTControlStepCode."""
     with pytest.raises(ConversionError):
         DPTControlStepCode.to_knx("")
     with pytest.raises(ConversionError):
         DPTControlStepCode.to_knx(0)