def test_on_response(self): with self.assertRaises(RuntimeError): self.stmgr_client.on_response(StatusCode.INVALID_PACKET, None, None) with self.assertRaises(RuntimeError): self.stmgr_client.on_response(StatusCode.OK, None, mock_protobuf.get_mock_instance()) self.stmgr_client.on_response(StatusCode.OK, None, mock_protobuf.get_mock_register_response()) self.assertTrue(self.stmgr_client.handle_register_response_called)
def test_on_response(self): with self.assertRaises(RuntimeError): self.stmgr_client.on_response(StatusCode.INVALID_PACKET, None, None) with self.assertRaises(RuntimeError): self.stmgr_client.on_response(StatusCode.OK, None, mock_protobuf.get_mock_instance()) self.stmgr_client.on_response( StatusCode.OK, None, mock_protobuf.get_mock_register_response()) self.assertTrue(self.stmgr_client.handle_register_response_called)
def get_mock_requst_packets(is_message): """Returns a list of valid IncomingPackets with non-zero REQID and the corresponding raw data""" pkt_list = [] raw_list = [] message_list = [mock_protobuf.get_mock_register_response(), mock_protobuf.get_mock_config(), mock_protobuf.get_mock_bolt(), mock_protobuf.get_mock_topology()] # normal packet (PhysicalPlan as request) for message in message_list: if is_message: reqid = REQID.generate_zero() else: reqid = REQID.generate() normal_pkt = convert_to_incoming_packet(reqid, message) pkt_list.append(normal_pkt) raw_list.append((reqid, message)) return pkt_list, raw_list
def get_a_mock_request_packet_and_raw(): """Returns a tuple of mock (IncomingPacket, REQID, RegisterResponse message)""" reqid = REQID.generate() message = mock_protobuf.get_mock_register_response() pkt = convert_to_incoming_packet(reqid, message) return pkt, reqid, message