Example #1
0
def small_app():
    """Flask application with few records and module scope.

    .. deprecated:: 2017-09-18
       Use ``app`` instead.
    """
    app = create_app()
    app.config.update({'DEBUG': 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 migrate

        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-small.xml',
                wait_for_results=True)
        es.indices.refresh('records-hep')

        yield app
Example #2
0
def small_app():
    """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 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-small.xml',
                wait_for_results=True)
        es.indices.refresh('records-hep')

        yield app
Example #3
0
def app(request):
    """Flask application fixture.

    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()
    app.config.update({'DEBUG': 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 migrate

        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-acceptance.xml.gz', wait_for_results=True)
        es.indices.refresh('records-hep')

        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
Example #5
0
def small_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 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)
        _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-small.xml", wait_for_results=True)
        es.indices.refresh("records-hep")

        yield app
Example #6
0
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
Example #7
0
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

        db.drop_all()
        db.create_all()
        init_all_storage_paths()

        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()
        es.indices.refresh('records-hep')  # Makes sure that all citation counts were added.

        yield app
Example #8
0
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
Example #9
0
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_ALWAYS_EAGER=True,
        CELERY_RESULT_BACKEND='cache',
        CELERY_CACHE_BACKEND='memory',
        CELERY_EAGER_PROPAGATES_EXCEPTIONS=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

        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
Example #10
0
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