예제 #1
0
    def loadapp(self, name='public'):
        app = flask_app.application_factory(name)
        app.testing = True
        app.test_client_class = KeystoneFlaskTestClient

        # NOTE(morgan): any unexpected 404s, not handled by the routed apis,
        # is a hard error and should not pass testing.
        def page_not_found_teapot(e):
            content = (
                'TEST PROGRAMMING ERROR - Reached a 404 from an unrouted (`%s`'
                ') path. Be sure the test is requesting the right resource '
                'and that all blueprints are registered with the flask app.' %
                flask.request.url)
            return content, 418

        app.register_error_handler(404, page_not_found_teapot)

        self.test_client = app.test_client
        self.cleanup_instance('test_client')
        return keystone_flask.setup_app_middleware(app)
예제 #2
0
파일: core.py 프로젝트: mahak/keystone
    def loadapp(self, name='public'):
        app = flask_app.application_factory(name)
        app.testing = True
        app.test_client_class = KeystoneFlaskTestClient

        # NOTE(morgan): any unexpected 404s, not handled by the routed apis,
        # is a hard error and should not pass testing.
        def page_not_found_teapot(e):
            content = (
                'TEST PROGRAMMING ERROR - Reached a 404 from an unrouted (`%s`'
                ') path. Be sure the test is requesting the right resource '
                'and that all blueprints are registered with the flask app.' %
                flask.request.url)
            return content, 418

        app.register_error_handler(404, page_not_found_teapot)

        self.test_client = app.test_client
        self.test_request_context = app.test_request_context
        self.cleanup_instance('test_request_context')
        self.cleanup_instance('test_client')
        return keystone_flask.setup_app_middleware(app)