def app(request): """Flask application fixture.""" app = create_app() app.config.update({'DEBUG': True}) with app.app_context(): # Imports must be local, otherwise tasks default to pickle serializer. from inspirehep.modules.migrator.tasks import add_citation_counts, migrate from inspirehep.modules.fixtures.files import init_all_storage_paths from inspirehep.modules.fixtures.users import init_users_and_permissions db.drop_all() db.create_all() sleep(10) # Makes sure that ES is up. _es = app.extensions['invenio-search'] list(_es.delete(ignore=[404])) list(_es.create(ignore=[400])) init_all_storage_paths() init_users_and_permissions() migrate('./inspirehep/demosite/data/demo-records.xml.gz', wait_for_results=True) es.indices.refresh( 'records-hep') # Makes sure that all HEP records were migrated. add_citation_counts() es.indices.refresh( 'records-hep') # Makes sure that all citation counts were added. yield app
def app(request): """Flask application fixture.""" app = create_app() app.config.update({"DEBUG": True}) with app.app_context(): # Imports must be local, otherwise tasks default to pickle serializer. from inspirehep.modules.migrator.tasks import add_citation_counts, migrate from inspirehep.modules.fixtures.files import init_all_storage_paths from inspirehep.modules.fixtures.users import init_users_and_permissions db.drop_all() db.create_all() sleep(10) # Makes sure that ES is up. _es = app.extensions["invenio-search"] list(_es.delete(ignore=[404])) list(_es.create(ignore=[400])) init_all_storage_paths() init_users_and_permissions() migrate("./inspirehep/demosite/data/demo-records.xml.gz", wait_for_results=True) es.indices.refresh("records-hep") # Makes sure that all HEP records were migrated. add_citation_counts() es.indices.refresh("records-hep") # Makes sure that all citation counts were added. yield app
def app(request): """Flask application fixture.""" app = create_app() def teardown(): with app.app_context(): db.drop_all() sleep(10) # Makes sure that ES is up. _es = app.extensions['invenio-search'] list(_es.delete(ignore=[400])) request.addfinalizer(teardown) with app.app_context(): # Imports must be local, otherwise tasks default to pickle serializer. from inspirehep.modules.migrator.tasks import add_citation_counts, migrate db.drop_all() db.create_all() sleep(10) # Makes sure that ES is up. _es = app.extensions['invenio-search'] list(_es.create(ignore=[400])) migrate('./inspirehep/demosite/data/demo-records.xml.gz', wait_for_results=True) es.indices.refresh( 'records-hep') # Makes sure that all HEP records were migrated. add_citation_counts(request_timeout=20) es.indices.refresh( 'records-hep') # Makes sure that all citation counts were added. yield app
def app(request): """Flask application fixture.""" app = create_app() def teardown(): with app.app_context(): db.drop_all() sleep(10) # Makes sure that ES is up. _es = app.extensions['invenio-search'] list(_es.delete(ignore=[404])) request.addfinalizer(teardown) with app.app_context(): # Imports must be local, otherwise tasks default to pickle serializer. from inspirehep.modules.migrator.tasks import add_citation_counts, migrate db.drop_all() db.create_all() sleep(10) # Makes sure that ES is up. _es = app.extensions['invenio-search'] list(_es.delete(ignore=[404])) list(_es.create(ignore=[400])) migrate('./inspirehep/demosite/data/demo-records.xml.gz', wait_for_results=True) es.indices.refresh('records-hep') # Makes sure that all HEP records were migrated. add_citation_counts(request_timeout=40) es.indices.refresh('records-hep') # Makes sure that all citation counts were added. yield app
def app(): """ Deprecated: do not use this fixture for new tests, unless for very specific use cases. Use `isolated_app` instead. Flask application with demosite data and without any database isolation: any db transaction performed during the tests are persisted into the db. Creates a Flask application with a simple testing configuration, then creates an application context and inside of it recreates all databases and indices from the fixtures. Finally it yields, so that all tests that explicitly use the ``app`` fixture have access to an application context. See: http://flask.pocoo.org/docs/0.12/appcontext/. """ app = create_app( DEBUG=False, # Tests may fail when turned on because of Flask bug (A setup function was called after the first request was handled. when initializing - when Alembic initialization) WTF_CSRF_ENABLED=False, CELERY_TASK_ALWAYS_EAGER=True, CELERY_RESULT_BACKEND='cache', CELERY_CACHE_BACKEND='memory', CELERY_TASK_EAGER_PROPAGATES=True, SECRET_KEY='secret!', RECORD_EDITOR_FILE_UPLOAD_FOLDER='tests/integration/editor/temp', TESTING=True, ) with app.app_context(): # Celery task imports must be local, otherwise their # configuration would use the default pickle serializer. from inspirehep.modules.migrator.tasks import add_citation_counts from inspirehep.modules.migrator.tasks import migrate_from_file db.session.close() db.drop_all() drop_alembic_version_table() alembic = Alembic(app=current_app) alembic.upgrade() _es = app.extensions['invenio-search'] list(_es.delete(ignore=[404])) list(_es.create(ignore=[400])) init_all_storage_paths() init_users_and_permissions() migrate_from_file('./inspirehep/demosite/data/demo-records.xml.gz', wait_for_results=True) es.indices.refresh( 'records-hep') # Makes sure that all HEP records were migrated. add_citation_counts() es.indices.refresh( 'records-hep') # Makes sure that all citation counts were added. yield app
def app(): """Flask application. Creates a Flask application with a simple testing configuration, then creates an application context and inside of it recreates all databases and indices from the fixtures. Finally it yields, so that all tests that explicitly use the ``app`` fixture have access to an application context. See: http://flask.pocoo.org/docs/0.12/appcontext/. """ app = create_app( DEBUG=True, WTF_CSRF_ENABLED=False, CELERY_TASK_ALWAYS_EAGER=True, CELERY_RESULT_BACKEND='cache', CELERY_CACHE_BACKEND='memory', CELERY_TASK_EAGER_PROPAGATES=True, SECRET_KEY='secret!', RECORD_EDITOR_FILE_UPLOAD_FOLDER='tests/integration/editor/temp', TESTING=True, ) with app.app_context(): # Celery task imports must be local, otherwise their # configuration would use the default pickle serializer. from inspirehep.modules.migrator.tasks import add_citation_counts, migrate_from_file db.drop_all() db.create_all() _es = app.extensions['invenio-search'] list(_es.delete(ignore=[404])) list(_es.create(ignore=[400])) init_all_storage_paths() init_users_and_permissions() init_collections() migrate_from_file('./inspirehep/demosite/data/demo-records.xml.gz', wait_for_results=True) es.indices.refresh( 'records-hep') # Makes sure that all HEP records were migrated. add_citation_counts() es.indices.refresh( 'records-hep') # Makes sure that all citation counts were added. yield app
def app(): """Flask application fixture.""" app = create_app( DEBUG=True, WTF_CSRF_ENABLED=False, CELERY_ALWAYS_EAGER=True, CELERY_RESULT_BACKEND='cache', CELERY_CACHE_BACKEND='memory', CELERY_EAGER_PROPAGATES_EXCEPTIONS=True, SECRET_KEY='secret!', TESTING=True, ) with app.app_context(): # Imports must be local, otherwise tasks default to pickle serializer. from inspirehep.modules.migrator.tasks import add_citation_counts, migrate from inspirehep.modules.fixtures.collections import init_collections from inspirehep.modules.fixtures.files import init_all_storage_paths from inspirehep.modules.fixtures.users import init_users_and_permissions db.drop_all() db.create_all() _es = app.extensions['invenio-search'] list(_es.delete(ignore=[404])) list(_es.create(ignore=[400])) init_all_storage_paths() init_users_and_permissions() init_collections() migrate('./inspirehep/demosite/data/demo-records.xml.gz', wait_for_results=True) es.indices.refresh( 'records-hep') # Makes sure that all HEP records were migrated. add_citation_counts() es.indices.refresh( 'records-hep') # Makes sure that all citation counts were added. yield app