def test_connectionstate_response(self): """Test string representation of KNX/IP ConnectionStateResponse.""" xknx = XKNX(loop=self.loop) connectionstate_response = ConnectionStateResponse(xknx) connectionstate_response.communication_channel_id = 23 self.assertEqual( str(connectionstate_response), '<ConnectionStateResponse CommunicationChannelID="23" status_code="ErrorCode.E_NO_ERROR" />')
def test_connectionstate_response(self): """Test string representation of KNX/IP ConnectionStateResponse.""" connectionstate_response = ConnectionStateResponse() connectionstate_response.communication_channel_id = 23 assert ( str(connectionstate_response) == '<ConnectionStateResponse communication_channel_id="23" status_code="ErrorCode.E_NO_ERROR" />' )
def test_disconnect_response(self): """Test parsing and streaming connection state response KNX/IP packet.""" raw = bytes((0x06, 0x10, 0x02, 0x08, 0x00, 0x08, 0x15, 0x21)) knxipframe = KNXIPFrame() knxipframe.from_knx(raw) assert isinstance(knxipframe.body, ConnectionStateResponse) assert knxipframe.body.communication_channel_id == 21 assert knxipframe.body.status_code == ErrorCode.E_CONNECTION_ID connectionstate_response = ConnectionStateResponse( communication_channel_id=21, status_code=ErrorCode.E_CONNECTION_ID, ) knxipframe2 = KNXIPFrame.init_from_body(connectionstate_response) assert knxipframe2.to_knx() == raw
def test_disconnect_response(self): """Test parsing and streaming connection state response KNX/IP packet.""" raw = (0x06, 0x10, 0x02, 0x08, 0x00, 0x08, 0x15, 0x21) xknx = XKNX() knxipframe = KNXIPFrame(xknx) knxipframe.from_knx(raw) self.assertTrue(isinstance(knxipframe.body, ConnectionStateResponse)) self.assertEqual(knxipframe.body.communication_channel_id, 21) self.assertEqual(knxipframe.body.status_code, ErrorCode.E_CONNECTION_ID) connectionstate_response = ConnectionStateResponse( xknx, communication_channel_id=21, status_code=ErrorCode.E_CONNECTION_ID) knxipframe2 = KNXIPFrame.init_from_body(connectionstate_response) self.assertEqual(knxipframe2.to_knx(), list(raw))