Beispiel #1
0
    def _create_dummy_request(self, path="/") -> Request:
        wsgi_request = APIRequestFactory().get(path)

        # Give access to all fields, so these can all be dumped.
        wsgi_request.user_scopes = UserScopes(query_params={},
                                              request_scopes=[])
        wsgi_request.user_scopes.has_any_scope = lambda *scopes: True
        wsgi_request.user_scopes.has_all_scopes = lambda *scopes: True

        # Wrap in DRF request object, like the view would have done.
        drf_request = Request(wsgi_request)
        drf_request.accepted_renderer = HALJSONRenderer()

        # Add what DSOViewMixin would have added
        drf_request.accept_crs = None
        drf_request.response_content_crs = None
        return drf_request