コード例 #1
0
    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)
コード例 #2
0
    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)
コード例 #3
0
ファイル: mock_generator.py プロジェクト: srkukarni/heron
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
コード例 #4
0
ファイル: mock_generator.py プロジェクト: AllenLiuGit/heron
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
コード例 #5
0
ファイル: mock_generator.py プロジェクト: srkukarni/heron
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
コード例 #6
0
ファイル: mock_generator.py プロジェクト: AllenLiuGit/heron
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