def __init__(self, api_endpoint):

        self.api_endpoint = api_endpoint

        def request_callback(request, uri, headers):
            """
            :param request: HTTP request
            :param uri: URI/URL to send the request
            :param headers: header of the HTTP request
            :return: httpretty response
            """

            resp = json.loads(example_solr_response)

            # Mimic the start, rows behaviour
            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

            # Mimic the filter "fl" behaviour
            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"
        )
Check that changes are possible and sticky
dataset/ETHPy150Open andycasey/ads/ads/tests/mocks.py/MockSolrResponse.__init__--crossover with--dataset/ETHPy150Open ellisonbg/altair/altair/tests/test_api.py/test_vl_spec_for_axis_changes