Exemple #1
0
def test_correct_name():
    global my_users
    data_delete()
    auth_register("*****@*****.**","password","Student","Citizen")
    user = auth_login("*****@*****.**",'password')
    
    # Changing user's email
    user_profile_setname(user['token'],'Citizen','Student')
    
    # Testing user_profile
    profile = user_profile(user['token'], user['u_id'])
    assert(profile['name_first'] == 'Citizen')
    assert(profile['name_last'] == 'Student')
Exemple #2
0
def user_profile_changename():
    token = request.form.get('token')
    name_first = request.form.get('name_first')
    name_last = request.form.get('name_last')
    try:
        user_profile_setname(token, name_first, name_last)
        return sendSuccess({

        })
    except ValueError as e:
        return sendError(400, "ValueError", e.args)
    except AccessError as a:
        return sendError(401, "AccessError", a.args)
Exemple #3
0
def test_name_no_inputs():
    global my_users
    data_delete()
    auth_register("*****@*****.**","password","Student","Citizen")
    user = auth_login("*****@*****.**",'password')
    
    
    # Changing user's name
    with pytest.raises(AccessError):
        user_profile_setname("","","")
    
    # Checking name
    profile = user_profile(user['token'], user['u_id'])
    assert(profile['name_last'] == 'Citizen')
    assert(profile['name_first'] == 'Student')
Exemple #4
0
def test_invalid_last_name():
    global my_users
    data_delete()
    auth_register("*****@*****.**","password","Student","Citizen")
    user = auth_login("*****@*****.**",'password')
    
    last_name = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"
    
    # Changing user's name
    with pytest.raises(ValueError):
        user_profile_setname(user['token'],'Student',last_name)
    
    # Checking email
    profile = user_profile(user['token'], user['u_id'])
    assert(profile['name_last'] == 'Citizen')
    assert(profile['name_first'] == 'Student')