def send(self, request, **kwargs): parsed_url = urlparse(request.path_url) method_name = parsed_url.path.replace('/', '_').replace('.', '_').replace( '-', '_') if hasattr(self.cls, method_name): match = getattr(self.cls, method_name) spec = inspect.getargspec(match) kwargs = {} if 'request' in spec.args: kwargs['request'] = request if 'method' in spec.args: kwargs['method'] = request.method if 'params' in spec.args: kwargs['params'] = dict(parse_qsl(parsed_url.query)) if 'headers' in spec.args: kwargs['headers'] = request.headers if 'url' in spec.args: kwargs['url'] = request.url if 'body' in spec.args: kwargs['body'] = request.body response = match(**kwargs) if isinstance(response, six.string_types): return StaticResponseFactory.GoodResponse(body=b(response), request=request) else: return response else: return StaticResponseFactory.BadResponse(status_code=404, request=request, body=b("Not found."))
def send(self, request, **kwargs): match = self.match_url(request) if match: return self.response_from_fixture(request=request, fixture_path=match) else: return StaticResponseFactory.BadResponse(status_code=404, request=request, body=b("'Not found.'"))
def _v1_delete_bad(self, request, method): if method == "DELETE": return StaticResponseFactory.BadResponse(request=request, body=b("bad request"), status_code=500)
def _v1_post_bad(self, request, method): if method == "POST": return StaticResponseFactory.BadResponse(request=request, body=b("bad request"), status_code=500)
def _test_json(self, request): return StaticResponseFactory.BadResponse( request=request, body=b("it's not over"), headers={'now': 'never'}, )
def _plans_api_reports_v1_users_test_plan(self, request, method): return StaticResponseFactory.BadResponse(request=request, body=b('bad request'), status_code=500)
def _plans_api_license_v1_plana_delete_bad(self, request, method): if method == 'DELETE': return StaticResponseFactory.BadResponse( request=request, body=b('bad request'), status_code=500)