예제 #1
0
 def test_value_special_chars(self):
     """Test parsing and streaming string with special chars."""
     raw = [0x48, 0x65, 0x79, 0x21, 0x3f,
            0x24, 0x20, 0xc4, 0xd6, 0xdc,
            0xe4, 0xf6, 0xfc, 0xdf]
     string = 'Hey!?$ ÄÖÜäöüß'
     self.assertEqual(DPTString.to_knx(string), raw)
     self.assertEqual(DPTString.from_knx(raw), string)
예제 #2
0
 def test_value_max_string(self):
     """Test parsing and streaming large string."""
     raw = [0x41, 0x41, 0x41, 0x41, 0x41,
            0x42, 0x42, 0x42, 0x42, 0x42,
            0x43, 0x43, 0x43, 0x43]
     string = 'AAAAABBBBBCCCC'
     self.assertEqual(DPTString.to_knx(string), raw)
     self.assertEqual(DPTString.from_knx(raw), string)
예제 #3
0
 def test_value_empty_string(self):
     """Test parsing and streaming empty string."""
     raw = [0x00, 0x00, 0x00, 0x00, 0x00,
            0x00, 0x00, 0x00, 0x00, 0x00,
            0x00, 0x00, 0x00, 0x00]
     string = ''
     self.assertEqual(DPTString.to_knx(string), raw)
     self.assertEqual(DPTString.from_knx(raw), string)
예제 #4
0
 def test_value_from_documentation(self):
     """Test parsing and streaming Example from documentation."""
     raw = [0x4B, 0x4E, 0x58, 0x20, 0x69,
            0x73, 0x20, 0x4F, 0x4B, 0x00,
            0x00, 0x00, 0x00, 0x00]
     string = 'KNX is OK'
     self.assertEqual(DPTString.to_knx(string), raw)
     self.assertEqual(DPTString.from_knx(raw), string)
예제 #5
0
 def test_from_knx_wrong_parameter_too_small(self):
     """Test parsing of KNX string with too less elements."""
     raw = (
         0x00,
         0x00,
         0x00,
         0x00,
         0x00,
         0x00,
         0x00,
         0x00,
         0x00,
         0x00,
         0x00,
         0x00,
         0x00,
     )
     with pytest.raises(ConversionError):
         DPTString.from_knx(raw)
예제 #6
0
 def test_value_special_chars(self):
     """Test parsing and streaming string with special chars."""
     raw = [
         0x48,
         0x65,
         0x79,
         0x21,
         0x3F,
         0x24,
         0x20,
         0xC4,
         0xD6,
         0xDC,
         0xE4,
         0xF6,
         0xFC,
         0xDF,
     ]
     string = "Hey!?$ ÄÖÜäöüß"
     self.assertEqual(DPTString.to_knx(string), raw)
     self.assertEqual(DPTString.from_knx(raw), string)
예제 #7
0
 def test_value_from_documentation(self):
     """Test parsing and streaming Example from documentation."""
     raw = (
         0x4B,
         0x4E,
         0x58,
         0x20,
         0x69,
         0x73,
         0x20,
         0x4F,
         0x4B,
         0x00,
         0x00,
         0x00,
         0x00,
         0x00,
     )
     string = "KNX is OK"
     assert DPTString.to_knx(string) == raw
     assert DPTString.from_knx(raw) == string
예제 #8
0
 def test_value_special_chars(self):
     """Test parsing and streaming string with special chars."""
     raw = (
         0x48,
         0x65,
         0x79,
         0x21,
         0x3F,
         0x24,
         0x20,
         0xC4,
         0xD6,
         0xDC,
         0xE4,
         0xF6,
         0xFC,
         0xDF,
     )
     string = "Hey!?$ ÄÖÜäöüß"
     assert DPTString.to_knx(string) == raw
     assert DPTString.from_knx(raw) == string
예제 #9
0
 def test_value_max_string(self):
     """Test parsing and streaming large string."""
     raw = (
         0x41,
         0x41,
         0x41,
         0x41,
         0x41,
         0x42,
         0x42,
         0x42,
         0x42,
         0x42,
         0x43,
         0x43,
         0x43,
         0x43,
     )
     string = "AAAAABBBBBCCCC"
     assert DPTString.to_knx(string) == raw
     assert DPTString.from_knx(raw) == string
예제 #10
0
 def test_value_empty_string(self):
     """Test parsing and streaming empty string."""
     raw = (
         0x00,
         0x00,
         0x00,
         0x00,
         0x00,
         0x00,
         0x00,
         0x00,
         0x00,
         0x00,
         0x00,
         0x00,
         0x00,
         0x00,
     )
     string = ""
     assert DPTString.to_knx(string) == raw
     assert DPTString.from_knx(raw) == string
예제 #11
0
 def test_to_knx_invalid_chars(self):
     """Test streaming string with invalid chars."""
     raw = (
         0x4D,
         0x61,
         0x74,
         0x6F,
         0x75,
         0x3F,
         0x00,
         0x00,
         0x00,
         0x00,
         0x00,
         0x00,
         0x00,
         0x00,
     )
     string = "Matouš"
     knx_string = "Matou?"
     assert DPTString.to_knx(string) == raw
     assert DPTString.from_knx(raw) == knx_string
예제 #12
0
 def test_from_knx_wrong_parameter_length(self, raw):
     """Test parsing of KNX string with wrong elements length."""
     with pytest.raises(ConversionError):
         DPTString.from_knx(raw)
예제 #13
0
 def test_to_knx_ascii_invalid_chars(self, string, knx_string, raw):
     """Test streaming ASCII string with invalid chars."""
     assert DPTString.to_knx(string) == raw
     assert DPTString.from_knx(raw) == knx_string
예제 #14
0
 def from_knx(self, payload: DPTArray) -> str:
     """Convert current payload to value."""
     return DPTString.from_knx(payload.value)
예제 #15
0
 def from_knx(self, payload):
     """Convert current payload to value."""
     return DPTString.from_knx(payload.value)