def search(self, request):
        """ Call search endpoint.
        """
        response = self.testapp.post('/_ah/spi/SupplierService.search',
                                     protojson.encode_message(request),
                                     content_type='application/json')

        self.assertEqual(response.status, '200 OK')

        return protojson.decode_message(SupplierCollectionMessage, response.body)
    def list(self):
        """ Call list endpoint.
        """

        response = self.testapp.post(
            '/_ah/spi/SupplierService.list',
            content_type='application/json')

        self.assertEqual(response.status, '200 OK')

        return protojson.decode_message(SupplierCollectionMessage, response.body)
    def list(self):
        """ Call list endpoint.
        """

        response = self.testapp.post('/_ah/spi/SupplierService.list',
                                     content_type='application/json')

        self.assertEqual(response.status, '200 OK')

        return protojson.decode_message(SupplierCollectionMessage,
                                        response.body)
    def search(self, request):
        """ Call search endpoint.
        """
        response = self.testapp.post('/_ah/spi/SupplierService.search',
                                     protojson.encode_message(request),
                                     content_type='application/json')

        self.assertEqual(response.status, '200 OK')

        return protojson.decode_message(SupplierCollectionMessage,
                                        response.body)
    def save(self, request):
        """ Call save endpoint.
        """

        response = self.testapp.post('/_ah/spi/CustomerService.save',
                                     protojson.encode_message(request),
                                     content_type='application/json')

        self.assertEqual(response.status, '200 OK')

        return protojson.decode_message(CustomerGetMessage, response.body)
Example #6
0
def _load_machine_provider_dimensions(pairs):
    """Loads from the given dict-like property.

  Args:
    pairs: A list of "<key>:<value>" strings.

  Returns:
    dimensions.Dimensions instance.
  """
    return protojson.decode_message(dimensions.Dimensions,
                                    json.dumps(_load_dict(pairs)))
Example #7
0
def _load_machine_provider_dimensions(pairs):
  """Loads from the given dict-like property.

  Args:
    pairs: A list of "<key>:<value>" strings.

  Returns:
    dimensions.Dimensions instance.
  """
  return protojson.decode_message(
      dimensions.Dimensions, json.dumps(_load_dict(pairs)))
def jsonish_dict_to_rpc(dictionary, rpc_message_type):
  """Converts the given dict to the specified RPC message type.

  Args:
    dictionary: A dict instance containing only values which can be
      encoded as JSON.
    rpc_message_type: A type inheriting from protorpc.message.Message.

  Returns:
    An object of type rpc_message_type.
  """
  return protojson.decode_message(rpc_message_type, json.dumps(dictionary))
def jsonish_dict_to_rpc(dictionary, rpc_message_type):
    """Converts the given dict to the specified RPC message type.

  Args:
    dictionary: A dict instance containing only values which can be
      encoded as JSON.
    rpc_message_type: A type inheriting from protorpc.message.Message.

  Returns:
    An object of type rpc_message_type.
  """
    return protojson.decode_message(rpc_message_type, json.dumps(dictionary))
Example #10
0
    def save(self, request):
        """ Call save endpoint.
        """

        response = self.testapp.post(
            '/_ah/spi/CustomerService.save',
            protojson.encode_message(request),
            content_type='application/json')

        self.assertEqual(response.status, '200 OK')

        return protojson.decode_message(CustomerGetMessage, response.body)
Example #11
0
def machine_type_pb2_to_entity(pb2):
    """Creates a MachineType entity from the given bots_pb2.MachineType.

  Args:
    pb2: A proto.bots_pb2.MachineType proto.

  Returns:
    A MachineType entity.
  """
    return MachineType(
        id=pb2.name,
        description=pb2.description,
        early_release_secs=pb2.early_release_secs,
        enabled=True,
        lease_duration_secs=pb2.lease_duration_secs,
        mp_dimensions=protojson.decode_message(
            machine_provider.Dimensions,
            json.dumps(dict(pair.split(':', 1) for pair in pb2.mp_dimensions)),
        ),
        target_size=pb2.target_size,
    )
Example #12
0
 def _loads_activity(self, content):
     return protojson.decode_message(messages.ActivityMessage, content)
Example #13
0
 def _loads_activity(self, content):
   return protojson.decode_message(messages.ActivityMessage, content)