How to use the placebo.utils.datautils.invoke_or_get function in placebo

To help you get started, we’ve selected a few placebo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github huseyinyilmaz / placebo / placebo / base.py View on Github external
def _get_body(self, url, headers, body):
        # we want to keep latest request to use do tests
        self._set_last_request(url, headers, body)
        if self.body is NotImplemented:
            raise NotImplementedError('To use placebo, you need to either '
                                      'provide body attribute or '
                                      'overwrite get_body method in subclass.')
        else:
            return invoke_or_get(self.body, url, headers, body)
github huseyinyilmaz / placebo / placebo / base.py View on Github external
def _get_url(self):
        """
        Returns: string_type or parse.ParseResult or parse SplitResult
        We have a vague return type for _get_url method
        because we could not generalise regex support for all
        backends. So we are directly passing result to backends.
        That way users can use regex that their backend provides.
        """
        if self.url is NotImplemented:
            raise NotImplementedError('To use placebo, you need to either '
                                      'provide url attribute or '
                                      'overwrite get_url method in subclass.')
        else:
            url = invoke_or_get(self.url)
            # if url is a string convert it to ParsedUrl
            # if isinstance(url, six.string_types):
            #     url = parse.urlparse(url)
            # TODO: check return type
            return url
github huseyinyilmaz / placebo / placebo / base.py View on Github external
def _get_headers(self, url, headers, body):
        headers = self.headers
        if headers is NotImplemented:
            headers = {}
        return invoke_or_get(headers, url, headers, body)
github huseyinyilmaz / placebo / placebo / base.py View on Github external
def _get_method(self):
        method = invoke_or_get(self.method)
        if not isinstance(method, six.string_types):
            raise ValueError('Method must be a string value.'
                             'Instead type %s provided. (%s)' %
                             (type(method), method))
        return method.upper()
github huseyinyilmaz / placebo / placebo / base.py View on Github external
def _get_status(self, url, headers, body):
        return invoke_or_get(self.status, url, headers, body)