示例#1
0
def celery_not_fail_on_eager_app(app):
    """."""
    instance_path = tempfile.mkdtemp()
    sorenson_output = tempfile.mkdtemp()

    os.environ.update(APP_INSTANCE_PATH=os.environ.get('INSTANCE_PATH',
                                                       instance_path), )

    app = create_app(
        DEBUG_TB_ENABLED=False,
        SQLALCHEMY_DATABASE_URI=os.environ.get(
            'SQLALCHEMY_DATABASE_URI',
            'postgresql+psycopg2://localhost/cds_testing'),
        TESTING=True,
        CELERY_ALWAYS_EAGER=True,
        CELERY_RESULT_BACKEND='cache',
        CELERY_CACHE_BACKEND='memory',
        CELERY_EAGER_PROPAGATES_EXCEPTIONS=False,
        CELERY_TRACK_STARTED=True,
        BROKER_TRANSPORT='redis',
        JSONSCHEMAS_HOST='cdslabs.cern.ch',
        CDS_SORENSON_OUTPUT_FOLDER=sorenson_output,
    )
    app.register_blueprint(files_rest_blueprint)

    with app.app_context():
        yield app

    shutil.rmtree(instance_path)
    shutil.rmtree(sorenson_output)
示例#2
0
def app():
    """Flask application fixture."""
    instance_path = tempfile.mkdtemp()

    os.environ.update(
        APP_INSTANCE_PATH=os.environ.get(
            'INSTANCE_PATH', instance_path),
    )

    app = create_app(
        DEBUG_TB_ENABLED=False,
        SQLALCHEMY_DATABASE_URI=os.environ.get(
            'SQLALCHEMY_DATABASE_URI',
            'postgresql+psycopg2://localhost/cds_testing'),
        #  SQLALCHEMY_ECHO=True,
        TESTING=True,
        CELERY_ALWAYS_EAGER=True,
        CELERY_RESULT_BACKEND='cache',
        CELERY_CACHE_BACKEND='memory',
        CELERY_EAGER_PROPAGATES_EXCEPTIONS=True,
        CELERY_TRACK_STARTED=True,
        BROKER_TRANSPORT='redis',
        JSONSCHEMAS_HOST='cdslabs.cern.ch',
        DEPOSIT_UI_ENDPOINT='{scheme}://{host}/deposit/{pid_value}',
        PIDSTORE_DATACITE_DOI_PREFIX='10.0000',
        # FIXME
        ACCOUNTS_JWT_ENABLE=False,
        THEO_LICENCE_KEY='CHANGE_ME',
    )
    app.register_blueprint(files_rest_blueprint)

    with app.app_context():
        yield app

    shutil.rmtree(instance_path)
def celery_not_fail_on_eager_app(app):
    """Celery configuration that does not raise errors inside test."""
    instance_path = tempfile.mkdtemp()

    os.environ.update(
        APP_INSTANCE_PATH=os.environ.get(
            'INSTANCE_PATH', instance_path),
    )

    app = create_app(
        DEBUG_TB_ENABLED=False,
        SQLALCHEMY_DATABASE_URI=os.environ.get(
            'SQLALCHEMY_DATABASE_URI',
            'postgresql+psycopg2://localhost/cds_testing'),
        TESTING=True,
        CELERY_ALWAYS_EAGER=True,
        CELERY_RESULT_BACKEND='cache',
        CELERY_CACHE_BACKEND='memory',
        CELERY_EAGER_PROPAGATES_EXCEPTIONS=False,
        CELERY_TRACK_STARTED=True,
        BROKER_TRANSPORT='redis',
        JSONSCHEMAS_HOST='cdslabs.cern.ch',
        PREVIEWER_PREFERENCE=['cds_video', ],
        RECORDS_UI_ENDPOINTS=dict(
            video_preview=dict(
                pid_type='depid',
                route='/deposit/<pid_value>/preview/video/<filename>',
                view_imp='cds.modules.previewer.views.preview_depid',
                record_class='cds.modules.deposit.api:Video',
            ),
        ),
        # FIXME
        ACCOUNTS_JWT_ENABLE=False,
    )
    app.register_blueprint(files_rest_blueprint)

    with app.app_context():
        yield app

    shutil.rmtree(instance_path)
示例#4
0
def base_app(request):
    """Flask application fixture."""
    instance_path = tempfile.mkdtemp()

    os.environ.update(APP_INSTANCE_PATH=instance_path)

    app = create_app(
        # CELERY_ALWAYS_EAGER=True,
        # CELERY_CACHE_BACKEND="memory",
        # CELERY_EAGER_PROPAGATES_EXCEPTIONS=True,
        # CELERY_RESULT_BACKEND="cache",
        SECRET_KEY="CHANGE_ME",
        SECURITY_PASSWORD_SALT="CHANGE_ME",
        MAIL_SUPPRESS_SEND=True,
        SQLALCHEMY_DATABASE_URI=os.environ.get('SQLALCHEMY_DATABASE_URI',
                                               'sqlite:///test.db'),
        TESTING=True,
    )

    with app.app_context():
        yield app

    # Teardown
    shutil.rmtree(instance_path)