def app(request): """Flask application fixture.""" instance_path = tempfile.mkdtemp() def init_app(app): app.config.update( LOGIN_DISABLED=False, MAIL_SUPPRESS_SEND=True, OAUTH2_CACHE_TYPE='simple', OAUTHLIB_INSECURE_TRANSPORT=True, SECRET_KEY='CHANGE_ME', SECURITY_DEPRECATED_PASSWORD_SCHEMES=[], SECURITY_PASSWORD_HASH='plaintext', SECURITY_PASSWORD_SALT='CHANGE_ME_ALSO', SECURITY_PASSWORD_SCHEMES=['plaintext'], SQLALCHEMY_DATABASE_URI=os.getenv( 'SQLALCHEMY_DATABASE_URI', 'sqlite:///' + os.path.join(instance_path, 'test.db')), SQLALCHEMY_TRACK_MODIFICATIONS=True, TESTING=True, WTF_CSRF_ENABLED=False, ) Babel(app) Mail(app) Menu(app) Breadcrumbs(app) InvenioDB(app) InvenioOAuth2Server(app) api_app = Flask('testapiapp', instance_path=instance_path) api_app.config.update(APPLICATION_ROOT='/api', ACCOUNTS_REGISTER_BLUEPRINT=True) init_app(api_app) InvenioAccountsREST(api_app) InvenioOAuth2ServerREST(api_app) app = Flask('testapp', instance_path=instance_path) init_app(app) InvenioAccountsUI(app) app.register_blueprint(accounts_blueprint) app.register_blueprint(server_blueprint) app.register_blueprint(settings_blueprint) app.wsgi_app = DispatcherMiddleware(app.wsgi_app, {'/api': api_app.wsgi_app}) with app.app_context(): if str(db.engine.url) != 'sqlite://' and \ not database_exists(str(db.engine.url)): create_database(str(db.engine.url)) db.create_all() def teardown(): with app.app_context(): if str(db.engine.url) != 'sqlite://': drop_database(str(db.engine.url)) shutil.rmtree(instance_path) request.addfinalizer(teardown) return app
('es', 'Spanish'), ('fr', 'French'), ('it', 'Italian'), ], ) InvenioAssets(app) InvenioTheme(app) InvenioI18N(app) Breadcrumbs(app) InvenioDB(app) InvenioAdmin(app) InvenioAccess(app) OAuth2Provider(app) InvenioOAuth2ServerREST(app) accounts = InvenioAccountsUI(app) InvenioAccountsREST(app) app.register_blueprint(blueprint_account) InvenioOAuth2Server(app) # Register blueprints app.register_blueprint(settings_blueprint) app.register_blueprint(server_blueprint) app.register_blueprint(blueprint_admin_ui) with app.app_context(): # Register a test scope current_oauth2server.register_scope( Scope('test:scope', help_text='Access to the homepage', group='test'))