Beispiel #1
0
def retrieve_model_by_properties(
    context, model, properties, require_exactly_one=False):
  url = get_service_endpoint_url(context, model)
  response = get_resource(context, '{0}?{1}'.format(
    url, urlencode(properties)))
  root = response.json().keys()[0]
  entries = response.json()[root][model.__tablename__]
  if require_exactly_one:
    assert len(entries) == 1
  if len(entries) > 0:
    return entries[0]
  return None
Beispiel #2
0
def perform_grouped_search(context, terms, result_name):
    url = get_service_endpoint_url(context, "search")
    handle_get_resource_and_name_it(context, url + "?q={0}&group_by_type=true".format(terms), result_name)
Beispiel #3
0
def post_to_named_endpoint(context, endpoint):
    text = handle_template_text(context, context.text)
    endpoint_url = get_service_endpoint_url(context, endpoint)
    context._response = post_to_endpoint(context, endpoint_url, text)
Beispiel #4
0
def query_with_bad_argument(context, resource_type, querystring):
  url = '{0}?{1}'.format(
      get_service_endpoint_url(context, resource_type),
      querystring)
  context.response = get_resource(context, url)
Beispiel #5
0
def query_resource_collection(context, resource_type, querystring):
  url = '{0}?{1}'.format(
      get_service_endpoint_url(context, resource_type),
      querystring)
  handle_get_resource_and_name_it(context, url, 'queryresultcollection')
def do_get_collection_for(context, typename, stubs_only=False):
  handle_get_resource_and_name_it(
      context,
      get_service_endpoint_url(context, typename) + '?__stubs_only',
      'collectionresource',
      )
Beispiel #7
0
def perform_grouped_search(context, terms, result_name):
    url = get_service_endpoint_url(context, 'search')
    handle_get_resource_and_name_it(
        context, url + '?q={0}&group_by_type=true'.format(terms), result_name)