Example #1
0
def test_init():
    """Test extension initialization."""
    app = Flask("testapp")
    ext = InvenioPIDStore(app)
    assert "invenio-pidstore" in app.extensions
    ext.register_minter("testminter", lambda a, b: "deadbeef-c0de-c0de-c0de-b100dc0ffee5")
    ext.register_fetcher("testfetcher", lambda a, b: "deadbeef-c0de-c0de-c0de-b100dc0ffee5")

    app = Flask("testapp")
    ext = InvenioPIDStore()
    assert "invenio-pidstore" not in app.extensions
    ext.init_app(app)
    assert "invenio-pidstore" in app.extensions
Example #2
0
def test_init():
    """Test extension initialization."""
    app = Flask('testapp')
    FlaskCLI(app)
    ext = InvenioPIDStore(app)
    assert 'invenio-pidstore' in app.extensions
    ext.register_minter('testminter',
                        lambda a, b: 'deadbeef-c0de-c0de-c0de-b100dc0ffee5')
    ext.register_fetcher('testfetcher',
                         lambda a, b: 'deadbeef-c0de-c0de-c0de-b100dc0ffee5')

    app = Flask('testapp')
    FlaskCLI(app)
    ext = InvenioPIDStore()
    assert 'invenio-pidstore' not in app.extensions
    ext.init_app(app)
    assert 'invenio-pidstore' in app.extensions
Example #3
0
def pidstore(app):
    """Initialize invenio-indexer app."""
    return InvenioPIDStore(app)
Example #4
0
InvenioAccounts(app)
InvenioAccess(app)
InvenioRecords(app)
InvenioRecordsUI(app)

InvenioRecordsREST(app)
InvenioDeposit(app)
InvenioDepositREST(app)

search = InvenioSearch(app)
search.register_mappings('deposits', 'invenio_deposit.mappings')

InvenioSearchUI(app)
InvenioREST(app)
InvenioIndexer(app)
InvenioPIDStore(app)
InvenioAdmin(app)
InvenioOAuth2Server(app)
InvenioOAuth2ServerREST(app)

InvenioFilesREST(app)

assets = InvenioAssets(app)
assets.env.register('invenio_search_ui_search_js', js)

app.register_blueprint(accounts_blueprint)

app.register_blueprint(settings_blueprint)
app.register_blueprint(server_blueprint)

Example #5
0
def app(request):
    """Flask application fixture."""
    instance_path = tempfile.mkdtemp()
    app_ = Flask('testapp', instance_path=instance_path)
    app_.config.update(
        # HTTPretty doesn't play well with Redis.
        # See gabrielfalcao/HTTPretty#110
        CACHE_TYPE='simple',
        CELERY_ALWAYS_EAGER=True,
        CELERY_CACHE_BACKEND='memory',
        CELERY_EAGER_PROPAGATES_EXCEPTIONS=True,
        CELERY_RESULT_BACKEND='cache',
        GITHUB_APP_CREDENTIALS=dict(
            consumer_key='changeme',
            consumer_secret='changeme',
        ),
        GITHUB_PID_FETCHER='doi_fetcher',
        LOGIN_DISABLED=False,
        OAUTHLIB_INSECURE_TRANSPORT=True,
        OAUTH2_CACHE_TYPE='simple',
        OAUTHCLIENT_REMOTE_APPS=dict(
            github=REMOTE_APP,
        ),
        SECRET_KEY='test_key',
        SERVER_NAME='testserver',
        SQLALCHEMY_TRACK_MODIFICATIONS=True,
        SQLALCHEMY_DATABASE_URI=os.getenv('SQLALCHEMY_DATABASE_URI',
                                          'sqlite:///test.db'),
        SECURITY_PASSWORD_HASH='plaintext',
        SECURITY_PASSWORD_SCHEMES=['plaintext'],
        SECURITY_DEPRECATED_PASSWORD_SCHEMES=[],
        TESTING=True,
        WTF_CSRF_ENABLED=False,
    )
    app_.config['OAUTHCLIENT_REMOTE_APPS']['github']['params'][
        'request_token_params'][
        'scope'] = 'user:email,admin:repo_hook,read:org'
    app_.url_map.converters['pid'] = PIDConverter

    celeryext = FlaskCeleryExt(app_)
    Babel(app_)
    Mail(app_)
    Menu(app_)
    Breadcrumbs(app_)
    InvenioAssets(app_)
    InvenioDB(app_)
    InvenioAccounts(app_)
    app_.register_blueprint(accounts_blueprint)
    InvenioOAuthClient(app_)
    app_.register_blueprint(oauthclient_blueprint)
    InvenioOAuth2Server(app_)
    app_.register_blueprint(server_blueprint)
    app_.register_blueprint(settings_blueprint)
    InvenioFormatter(app_)

    from .helpers import doi_fetcher
    pidstore = InvenioPIDStore(app_)
    pidstore.register_fetcher('doi_fetcher', doi_fetcher)

    InvenioJSONSchemas(app_)
    InvenioRecords(app_)
    InvenioSearch(app_)
    InvenioIndexer(app_)
    InvenioFilesREST(app_)
    InvenioRecordsREST(app_)
    InvenioDepositREST(app_)
    InvenioWebhooks(app_)
    celeryext.celery.flask_app = app_  # Make sure both apps are the same!
    app_.register_blueprint(webhooks_blueprint)
    InvenioGitHub(app_)
    app_.register_blueprint(github_blueprint)
    app_.register_blueprint(github_badge_blueprint)

    with app_.app_context():
        yield app_

    shutil.rmtree(instance_path)