Beispiel #1
0
    def get_content(self, response):
        content, err, meta, code = get_content_from_response(response)

        # Since unittests use class object and not instances
        # This is the only workaround to set a persistent variable:
        # abuse of the __class__ property

        self.__class__.latest_response = {
            "metadata": meta,
            "content": content,
            "errors": err,
            "status": code,
        }
        return content
    def explode_response(
        self, api_output, get_all=False,
        get_error=False, get_status=False, get_meta=False
    ):

        from restapi.rest.response import get_content_from_response
        content, err, meta, code = get_content_from_response(api_output)

        if get_error:
            return err
        elif get_meta:
            return meta
        elif get_status:
            return code
        elif get_all:
            return content, err, code

        return content