コード例 #1
0
ファイル: test_models.py プロジェクト: vypha/weko
def test_profile_updating(base_app):
    base_app.config.update(USERPROFILES_EXTEND_SECURITY_FORMS=True)
    WekoUserProfiles(base_app)
    app = base_app

    with app.app_context():
        user = User(email='lollorosso', password='******')
        db.session.add(user)
        db.session.commit()

        assert user.profile is None

        profile = UserProfile(
            username='******',
            full_name='Test T. User'
        )
        user.profile = profile
        user.profile.username = '******'
        assert user.profile.username == 'Different_Name'
        assert profile.username == 'Different_Name'
コード例 #2
0
def test_profile_in_registration(base_app):
    """Test accounts registration form."""
    base_app.config.update(USERPROFILES_EXTEND_SECURITY_FORMS=True)
    WekoUserProfiles(base_app)
    base_app.register_blueprint(blueprint_ui_init)
    app = base_app

    with app.test_request_context():
        register_url = url_for_security('register')

    with app.test_client() as client:
        resp = client.get(register_url)
        assert 'profile.username' in resp.get_data(as_text=True)
        assert 'profile.full_name' in resp.get_data(as_text=True)

        data = {
            'email': '*****@*****.**',
            'password': '******',
            'profile.username': '******',
            'profile.full_name': 'Test C. User',
        }
        resp = client.post(register_url, data=data, follow_redirects=True)

    with app.test_request_context():
        user = User.query.filter_by(email='*****@*****.**').one()
        assert user.profile.username == 'TestUser'
        assert user.profile.full_name == 'Test C. User'

    with app.test_client() as client:
        resp = client.get(register_url)
        data = {
            'email': '*****@*****.**',
            'password': '******',
            'profile.username': '******',
            'profile.full_name': 'Same Username',
        }
        resp = client.post(register_url, data=data)
        assert resp.status_code == 200
        assert 'profile.username' in resp.get_data(as_text=True)
コード例 #3
0
ファイル: test_admin.py プロジェクト: vypha/weko
def test_admin(app):
    """Test flask-admin interace."""
    WekoUserProfiles(app)

    assert isinstance(user_profile_adminview, dict)

    assert 'model' in user_profile_adminview
    assert 'modelview' in user_profile_adminview

    admin = Admin(app, name="Test")

    user_model = user_profile_adminview.pop('model')
    user_view = user_profile_adminview.pop('modelview')
    admin.add_view(user_view(user_model, db.session, **user_profile_adminview))

    with app.test_request_context():
        request_url = url_for('userprofile.index_view')

    with app.app_context():
        with app.test_client() as client:
            res = client.get(request_url, follow_redirects=True)
            assert res.status_code == 200
            assert b'Username' in (res.get_data())
            assert b'Full Name' in (res.get_data())
コード例 #4
0
def test_init():
    """Test extension initialization."""
    app = Flask('testapp')
    app.config.update(ACCOUNTS_USE_CELERY=False)
    Babel(app)
    Mail(app)
    Menu(app)
    InvenioDB(app)
    InvenioAccounts(app)
    ext = WekoUserProfiles(app)
    assert 'weko-user-profiles' in app.extensions

    app = Flask('testapp')
    app.config.update(ACCOUNTS_USE_CELERY=False)
    Babel(app)
    Mail(app)
    Menu(app)
    InvenioDB(app)
    InvenioAccounts(app)
    ext = WekoUserProfiles()
    assert 'weko-user-profiles' not in app.extensions
    ext.init_app(app)
    assert 'weko-user-profiles' in app.extensions
コード例 #5
0
ファイル: conftest.py プロジェクト: weko3-dev35/weko
def _init_userprofiles_app(app_):
    """Init UserProfiles modules."""
    WekoUserProfiles(app_)
    app_.register_blueprint(blueprint_ui_init)
    return app_
コード例 #6
0
ファイル: app.py プロジェクト: weko3-dev35/weko
    SQLALCHEMY_DATABASE_URI=os.environ.get(
        'SQLALCHEMY_DATABASE_URI', 'sqlite:///test.db'
    ),
    SQLALCHEMY_TRACK_MODIFICATIONS=True,
    WTF_CSRF_ENABLED=False,
)
Babel(app)
InvenioMail(app)
InvenioI18N(app)
InvenioDB(app)
if INVENIO_ASSETS_AVAILABLE:
    InvenioAssets(app)
if INVENIO_THEME_AVAILABLE:
    InvenioTheme(app)
InvenioAccess(app)
InvenioAccounts(app)
app.register_blueprint(blueprint)
WekoUserProfiles(app)
app.register_blueprint(blueprint2)
app.register_blueprint(blueprint_api_init)
app.register_blueprint(blueprint_ui_init)

InvenioAdmin(app)
app.register_blueprint(blueprint_admin_ui)


@app.route('/')
def index():
    """Example index page route."""
    return redirect(url_for('invenio_userprofiles.profile'))