def create_guest_user():
    """ Create a guest user if it doesn't exist """
    if not User.query.filter_by(name='guest').count():
        user = UserFactory()
        user.name = 'guest'
        user.email = '*****@*****.**'
        user.set_password('53CR3t_p4zZW0rD')
        user.role = Role.query.filter_by(name='Guest').first().id
        user.save()
Ejemplo n.º 2
0
def create_user(mycodo_db, role_id, name, password):
    """ Create fake admin user """
    new_user = UserFactory()
    new_user.name = name
    new_user.set_password(password)
    new_user.role_id = role_id
    mycodo_db.add(new_user)
    mycodo_db.commit()
    return new_user
Ejemplo n.º 3
0
def create_user(mycodo_db, role_id, name, password):
    """ Create fake admin user """
    new_user = UserFactory()
    new_user.name = name
    new_user.set_password(password)
    new_user.role_id = role_id
    mycodo_db.add(new_user)
    mycodo_db.commit()
    return new_user
def create_admin_user():
    """ Create an admin user if it doesn't exist """
    if not User.query.filter_by(name='admin').count():
        user = UserFactory()
        user.name = 'admin'
        user.set_password('53CR3t_p4zZW0rD')
        user.save()
        user.role = Role.query.filter_by(name='Admin').first().id
        user.save()
Ejemplo n.º 5
0
def create_guest_user():
    """ Create a guest user if it doesn't exist """
    if not User.query.filter_by(name='guest').count():
        user = UserFactory()
        user.name = 'guest'
        user.email = '*****@*****.**'
        user.set_password('53CR3t_p4zZW0rD')
        user.role_id = Role.query.filter_by(name='Guest').first().id
        user.language = 'en'
        user.save()
Ejemplo n.º 6
0
def create_admin_user():
    """ Create an admin user if it doesn't exist """
    if not User.query.filter_by(name='admin').count():
        user = UserFactory()
        user.name = 'admin'
        user.set_password('53CR3t_p4zZW0rD')
        user.language = 'en'
        user.save()
        user.role_id = Role.query.filter_by(name='Admin').first().id
        user.save()
Ejemplo n.º 7
0
def create_admin_user():
    """Create an admin user if it doesn't exist."""
    if not User.query.filter_by(name='admin').count():
        user = UserFactory()
        user.name = 'admin'
        user.set_password('53CR3t_p4zZW0rD')
        user.api_key = b'secret_admin_api_key'
        user.language = 'en'
        user.save()
        user.role_id = Role.query.filter_by(name='Admin').first().id
        user.save()
Ejemplo n.º 8
0
def test_user_can_login(_, testapp, user_db):
    """ user logs in and sees a nav bar """
    # Build a user that we can login with
    norm_user = UserFactory()
    norm_user.set_password('something_secrete')
    user_db.add(norm_user)
    user_db.commit()

    # user fills out login page
    login_user(testapp, norm_user.user_name, 'something_secrete')

    # user sees the main page
    res = testapp.get('/').maybe_follow()
    assert res.status_code == 200
    # sees navbar
    assert 'Live' in res
    assert 'Graph' in res
    assert 'Sensor' in res
    assert 'Relay' in res
    assert 'Method' in res
    assert 'PID' in res
    assert 'Timer' in res
    assert 'Help' in res
    assert 'Admin' in res
Ejemplo n.º 9
0
def test_user_can_login(_, testapp, user_db):
    """ user logs in and sees a nav bar """
    # Build a user that we can login with
    norm_user = UserFactory()
    norm_user.set_password('something_secrete')
    user_db.add(norm_user)
    user_db.commit()

    # user fills out login page
    login_user(testapp, norm_user.user_name, 'something_secrete')

    # user sees the main page
    res = testapp.get('/').maybe_follow()
    assert res.status_code == 200
    # sees navbar
    assert 'Live' in res
    assert 'Graph' in res
    assert 'Sensor' in res
    assert 'Relay' in res
    assert 'Method' in res
    assert 'PID' in res
    assert 'Timer' in res
    assert 'Help' in res
    assert 'Admin' in res