def setUpClass(cls): """Instantiate an app for use with a SQLite database.""" _, db = tempfile.mkstemp(suffix='.sqlite') cls.app = Flask('foo') cls.app.config['CLASSIC_DATABASE_URI'] = f'sqlite:///{db}' with cls.app.app_context(): classic.init_app(cls.app)
def in_memory_db(): """Provide an in-memory sqlite database for testing purposes.""" app = Flask('foo') app.config['CLASSIC_DATABASE_URI'] = 'sqlite://' with app.app_context(): classic.init_app(app) classic.create_all() try: yield classic.current_session() except Exception: raise finally: classic.drop_all()
def create_web_app() -> Flask: """Initialize an instance of the extractor backend service.""" app = Flask('metadata') classic.init_app(app) app.config.from_pyfile('config.py') app.register_blueprint(routes.blueprint) app.errorhandler(Forbidden)(jsonify_exception) app.errorhandler(NotFound)(jsonify_exception) app.errorhandler(BadRequest)(jsonify_exception) app.errorhandler(Unauthorized)(jsonify_exception) wrap(app, [auth.AuthMiddleware]) return app