

def __init__(self, api_endpoint):
    '\n        :param api_endpoint: name of the API end point\n        '
    self.api_endpoint = api_endpoint

    def request_callback(request, uri, headers):
        '\n            :param request: HTTP request\n            :param uri: URI/URL to send the request\n            :param headers: header of the HTTP request\n            :return: httpretty response\n            '
        resp = json.loads(example_solr_response)
        rows = int(request.querystring.get('rows', [len(resp['response']['docs'])])[0])
        rows = min(rows, 300)
        start = int(request.querystring.get('start', [0])[0])
        try:
            resp['response']['docs'] = resp['response']['docs'][start:(start + rows)]
        except IndexError:
            resp['response']['docs'] = resp['response']['docs'][start:]
        resp['responseHeader']['params']['rows'] = rows
        fl = request.querystring.get('fl', ['id'])
        resp['response']['docs'] = [{field: doc.get(field) for field in fl} for doc in resp['response']['docs']]
        resp['responseHeader']['params']['fl'] = fl
        return (200, headers, json.dumps(resp))
    HTTPretty.register_uri(HTTPretty.GET, self.api_endpoint, body=request_callback, content_type='application/json')

dataset/ETHPy150Open andycasey/ads/ads/tests/mocks.py MockSolrResponse.__init__/original