コード例 #1
0
    def __call__(self, environ, start_response):
        request = self._create_request(environ)
        request_mock = _RequestObjectProxy(request.prepare())

        if request_mock.body is None:
            request_mock.body = ""

        response = self.adapter.match(request_mock)
        response = self._create_response(response)
        return response(environ, start_response)
コード例 #2
0
    def __call__(self, environ, start_response):
        request = self._create_request(environ)
        request.url = request.url.split("?")[0]
        request_mock = _RequestObjectProxy(request.prepare())

        # if request_mock.body is None:
        if not (hasattr(request_mock, 'body')) or request_mock.body is None:
            request_mock.body = "{}"

        response = self.adapter.match(request_mock)
        response = self._create_response(response)
        return response(environ, start_response)
コード例 #3
0
ファイル: adapter.py プロジェクト: avsyap/fitbit
    def send(self, request, **kwargs):
        request = _RequestObjectProxy(request,
                                      case_sensitive=self._case_sensitive,
                                      **kwargs)
        self._add_to_history(request)

        for matcher in reversed(self._matchers):
            try:
                resp = matcher(request)
            except Exception:
                request._matcher = weakref.ref(matcher)
                raise

            if resp is not None:
                request._matcher = weakref.ref(matcher)
                resp.connection = self
                return resp

        raise exceptions.NoMockAddress(request)
コード例 #4
0
ファイル: adapter.py プロジェクト: jamielennox/requests-mock
    def send(self, request, **kwargs):
        request = _RequestObjectProxy(request,
                                      case_sensitive=self._case_sensitive,
                                      **kwargs)
        self._add_to_history(request)

        for matcher in reversed(self._matchers):
            try:
                resp = matcher(request)
            except Exception:
                request._matcher = weakref.ref(matcher)
                raise

            if resp is not None:
                request._matcher = weakref.ref(matcher)
                resp.connection = self
                return resp

        raise exceptions.NoMockAddress(request)
コード例 #5
0
ファイル: adapter.py プロジェクト: peachfinance/requests-mock
    def send(self, request, **kwargs):
        request = _RequestObjectProxy(request,
                                      case_sensitive=self._case_sensitive,
                                      **kwargs)
        self._add_to_history(request)

        for matcher in reversed(self._matchers):
            try:
                resp = matcher(request)
            except Exception:
                request._matcher = weakref.ref(matcher)
                raise

            if resp is not None:
                request._matcher = weakref.ref(matcher)
                resp.connection = self
                logger.debug('{} {} {}'.format(request._request.method,request._request.url, resp.status_code))
                return resp

        raise exceptions.NoMockAddress(request)