Example #1
0
def test_init_rest():
    """Test REST extension initialization."""
    app = Flask('testapp')
    Babel(app)
    Mail(app)
    InvenioDB(app)
    ext = InvenioAccountsREST(app)
    assert 'invenio-accounts' in app.extensions
    assert 'security' not in app.blueprints.keys()

    app = Flask('testapp')
    Babel(app)
    Mail(app)
    InvenioDB(app)
    ext = InvenioAccountsREST()
    assert 'invenio-accounts' not in app.extensions
    assert 'security' not in app.blueprints.keys()
    ext.init_app(app)
    assert 'invenio-accounts' in app.extensions
    assert 'security' not in app.blueprints.keys()

    app = Flask('testapp')
    app.config['ACCOUNTS_REGISTER_BLUEPRINT'] = True
    Babel(app)
    Mail(app)
    InvenioDB(app)
    ext = InvenioAccountsREST()
    assert 'invenio-accounts' not in app.extensions
    assert 'security' not in app.blueprints.keys()
    ext.init_app(app)
    assert 'invenio-accounts' in app.extensions
    assert 'security' in app.blueprints.keys()
def test_init_rest():
    """Test REST extension initialization."""
    app = Flask('testapp')
    Babel(app)
    Mail(app)
    InvenioDB(app)
    ext = InvenioAccountsREST(app)
    assert 'invenio-accounts' in app.extensions
    assert 'security' not in app.blueprints.keys()

    app = Flask('testapp')
    Babel(app)
    Mail(app)
    InvenioDB(app)
    ext = InvenioAccountsREST()
    assert 'invenio-accounts' not in app.extensions
    assert 'security' not in app.blueprints.keys()
    ext.init_app(app)
    assert 'invenio-accounts' in app.extensions
    assert 'security' not in app.blueprints.keys()

    app = Flask('testapp')
    app.config['ACCOUNTS_REGISTER_BLUEPRINT'] = True
    Babel(app)
    Mail(app)
    InvenioDB(app)
    ext = InvenioAccountsREST()
    assert 'invenio-accounts' not in app.extensions
    assert 'security' not in app.blueprints.keys()
    ext.init_app(app)
    assert 'invenio-accounts' in app.extensions
    assert 'security' in app.blueprints.keys()
def test_init_rest():
    """Test REST extension initialization."""
    app = Flask("testapp")
    app.config["SECRET_KEY"] = "CHANGEME"
    Babel(app)
    Mail(app)
    InvenioDB(app)
    ext = InvenioAccountsREST(app)
    assert "invenio-accounts" in app.extensions
    assert "security" not in app.blueprints.keys()
    assert "security_email_templates" in app.blueprints.keys()

    app = Flask("testapp")
    app.config["SECRET_KEY"] = "CHANGEME"
    Babel(app)
    Mail(app)
    InvenioDB(app)
    ext = InvenioAccountsREST()
    assert "invenio-accounts" not in app.extensions
    assert "security" not in app.blueprints.keys()
    ext.init_app(app)
    assert "invenio-accounts" in app.extensions
    assert "security" not in app.blueprints.keys()
    assert "security_email_templates" in app.blueprints.keys()

    app = Flask("testapp")
    app.config["SECRET_KEY"] = "CHANGEME"
    app.config["ACCOUNTS_REGISTER_BLUEPRINT"] = True
    Babel(app)
    Mail(app)
    InvenioDB(app)
    ext = InvenioAccountsREST()
    assert "invenio-accounts" not in app.extensions
    assert "security" not in app.blueprints.keys()
    ext.init_app(app)
    assert "invenio-accounts" in app.extensions
    assert "security" in app.blueprints.keys()
    assert "security_email_templates" in app.blueprints.keys()