def before(self): self.resource = HelloResource('body') self.api.add_route(self.test_route, self.resource) self.bytes_resource = HelloResource('body, bytes') self.api.add_route('/bytes', self.bytes_resource) self.data_resource = HelloResource('data') self.api.add_route('/data', self.data_resource) self.chunked_resource = HelloResource('stream') self.api.add_route('/chunked-stream', self.chunked_resource) self.stream_resource = HelloResource('stream, stream_len') self.api.add_route('/stream', self.stream_resource) self.filelike_resource = HelloResource('stream, stream_len, filelike') self.api.add_route('/filelike', self.filelike_resource) self.filelike_helper_resource = HelloResource( 'stream, stream_len, filelike, use_helper') self.api.add_route('/filelike-helper', self.filelike_helper_resource) self.no_status_resource = NoStatusResource() self.api.add_route('/nostatus', self.no_status_resource) self.root_resource = testing.TestResource() self.api.add_route('/', self.root_resource)
def test_dont_auto_parse_by_default(self): self.resource = testing.TestResource() self.api.add_route('/', self.resource) headers = {'Content-Type': 'application/x-www-form-urlencoded'} self.simulate_request('/', body='q=42', headers=headers) req = self.resource.req self.assertIs(req.get_param('q'), None)
def before(self): self.resource = testing.TestResource() book_resource = BookResource() self.api.add_route('/books', book_resource) self.expected_book_0 = { 'title': 'Don Quijote de la Mancha', 'author': 'Miguel de Cervantes', 'id': 1 } self.expected_book_1 = { 'title': 'Romeo y Julieta', 'author': 'William Shakespeare', 'id': 2 }
def simulate(): app = falcon.API(middleware=[RequireHTTPS()]) app.add_route(_TEST_PATH, testing.TestResource()) def simulate(protocol, headers=None): env = testing.create_environ( method='GET', scheme=protocol, path=_TEST_PATH, query_string='', headers=headers, ) srmock = testing.StartResponseMock() iterable = app(env, srmock) return testing.Result(iterable, srmock.status, srmock.headers) return simulate
def prepare(self): self.resource = HelloResource('body') self.api.add_route(self.test_route, self.resource) self.bytes_resource = HelloResource('body, bytes') self.api.add_route('/bytes', self.bytes_resource) self.data_resource = HelloResource('data') self.api.add_route('/data', self.data_resource) self.chunked_resource = HelloResource('stream') self.api.add_route('/chunked-stream', self.chunked_resource) self.stream_resource = HelloResource('stream, stream_len') self.api.add_route('/stream', self.stream_resource) self.no_status_resource = NoStatusResource() self.api.add_route('/nostatus', self.no_status_resource) self.root_resource = testing.TestResource() self.api.add_route('', self.root_resource)
def before(self): self.resource = testing.TestResource() self.api.add_route('/', self.resource)
def before(self): self.resource = testing.TestResource()
def prepare(self): self.resource = testing.TestResource()
def resource(): return testing.TestResource()
def prepare(self): self.resource = testing.TestResource() self.api.add_route(self.test_route, self.resource)