Пример #1
0
  def test_get_dict_from_config(self):
    # testing creating auto-typed dict from protobuf Config message

    # try with config <str -> str>
    test_config_1 = {"key1": "string_value",
                     "key2": "12",
                     "key3": "1.50",
                     "key4": "false"}
    expected_1 = {"key1": "string_value",
                  "key2": 12,
                  "key3": 1.50,
                  "key4": False}
    proto_config = mock_protobuf.get_mock_config(config_dict=test_config_1)
    ret = PhysicalPlanHelper._get_dict_from_config(proto_config)
    self.assertEqual(ret, expected_1)

    # try with config <str -> any object>
    test_config_2 = {"key1": "string",
                     "key2": True,
                     "key3": 1.20,
                     "key4": (1, 2, 3, "hello"),
                     "key5": {"key5_1": 1, "key5_2": "value"},
                     "key6": [1, 2, 3, 4, 5.0]}

    proto_config = mock_protobuf.get_mock_config(config_dict=test_config_2)
    ret = PhysicalPlanHelper._get_dict_from_config(proto_config)
    self.assertEqual(ret, test_config_2)
Пример #2
0
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
Пример #3
0
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