def test_hpai(self): """Test parsing and streaming HPAI KNX/IP fragment.""" raw = ((0x08, 0x01, 0xc0, 0xa8, 0x2a, 0x01, 0x84, 0x95)) hpai = HPAI() self.assertEqual(hpai.from_knx(raw), 8) self.assertEqual(hpai.ip_addr, '192.168.42.1') self.assertEqual(hpai.port, 33941) hpai2 = HPAI(ip_addr='192.168.42.1', port=33941) self.assertEqual(hpai2.to_knx(), list(raw))
def test_hpai(self): """Test parsing and streaming HPAI KNX/IP fragment.""" raw = (0x08, 0x01, 0xC0, 0xA8, 0x2A, 0x01, 0x84, 0x95) hpai = HPAI() assert hpai.from_knx(raw) == 8 assert hpai.ip_addr == "192.168.42.1" assert hpai.port == 33941 hpai2 = HPAI(ip_addr="192.168.42.1", port=33941) assert hpai2.to_knx() == list(raw)
def test_hpai_tcp(self): """Test parsing and streaming HPAI KNX/IP fragment.""" raw = bytes((0x08, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)) hpai = HPAI() assert hpai.from_knx(raw) == 8 assert hpai.ip_addr == "0.0.0.0" assert hpai.port == 0 assert hpai.protocol == HostProtocol.IPV4_TCP assert hpai.route_back hpai2 = HPAI(ip_addr="0.0.0.0", port=0, protocol=HostProtocol.IPV4_TCP) assert hpai2.to_knx() == raw
def test_hpai_udp(self): """Test parsing and streaming HPAI KNX/IP fragment.""" raw = bytes((0x08, 0x01, 0xC0, 0xA8, 0x2A, 0x01, 0x84, 0x95)) hpai = HPAI() assert hpai.from_knx(raw) == 8 assert hpai.ip_addr == "192.168.42.1" assert hpai.port == 33941 assert hpai.protocol == HostProtocol.IPV4_UDP assert not hpai.route_back hpai2 = HPAI(ip_addr="192.168.42.1", port=33941) assert hpai2.to_knx() == raw assert not hpai2.route_back