コード例 #1
0
    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)
コード例 #2
0
ファイル: test_query_params.py プロジェクト: lumberj/falcon
    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)
コード例 #3
0
 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
     }
コード例 #4
0
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
コード例 #5
0
ファイル: test_hello.py プロジェクト: anthrax3/falcon
    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)
コード例 #6
0
ファイル: test_query_params.py プロジェクト: lumberj/falcon
 def before(self):
     self.resource = testing.TestResource()
     self.api.add_route('/', self.resource)
コード例 #7
0
 def before(self):
     self.resource = testing.TestResource()
コード例 #8
0
 def prepare(self):
     self.resource = testing.TestResource()
コード例 #9
0
def resource():
    return testing.TestResource()
コード例 #10
0
ファイル: test_headers.py プロジェクト: anthrax3/falcon
 def prepare(self):
     self.resource = testing.TestResource()
     self.api.add_route(self.test_route, self.resource)