Exemple #1
0
def test_login_corr():
    global my_users
    data_delete()
    user = auth_register("*****@*****.**", "password", "Student", "Citizen")
    userDict = auth_login("*****@*****.**", 'password')
    assert userDict['u_id'] == user['u_id']
    assert get_user_from_token(userDict['token']) == my_users[0]
Exemple #2
0
def test_act_tok():
    global my_users
    data_delete()

    auth_register("*****@*****.**", "password", "Student", "Citizen")
    userDict = auth_login("*****@*****.**", 'password')
    is_success = auth_logout(userDict['token'])
    assert is_success == True
Exemple #3
0
def test_invalid_id():
    global my_users
    data_delete()
    auth_register("*****@*****.**","password","Student","Citizen")
    user = auth_login("*****@*****.**",'password')
    
    # Testing user_profile
    with pytest.raises(ValueError):
        user_profile(user['token'], '546')
Exemple #4
0
def test_handle_already_used2():
    global my_users
    data_delete()
    auth_register("*****@*****.**", "password", "Studentabcde", "Citizen")
    auth_register("*****@*****.**", "password", "Studentabcde", "Citizen")
    user = auth_login("*****@*****.**", 'password')

    userClass = get_user_from_token(user['token'])
    # Checking handle

    assert (userClass.get_handle_str() == "studentabcdecitizen1")
Exemple #5
0
def user_login():
    """ Function that logs the user into the system """
    email = request.form.get('email')
    password = request.form.get('password')
    try:
        returnDict = auth_login(email, password)
        return sendSuccess({
            'u_id': returnDict['u_id'],
            'token': returnDict['token']
        })
    except ValueError as e:
        return sendError(400, "ValueError", e.args)
Exemple #6
0
def test_correct_profile():
    global my_users
    data_delete()
    auth_register("*****@*****.**","password","Student","Citizen")
    userDict = auth_login("*****@*****.**",'password')
    # Testing user_profile
    profile = user_profile(userDict['token'], userDict['u_id'])
    
    assert(profile['email'] == '*****@*****.**')
    assert(profile['name_first'] == 'Student')
    assert(profile['name_last'] == 'Citizen')
    assert(profile['handle_str'] == 'studentcitizen')
Exemple #7
0
def test_correct_sethandle():
    global my_users
    data_delete()
    auth_register("*****@*****.**","password","Student","Citizen")
    user = auth_login("*****@*****.**",'password')
    
    # Changing user's handle
    user_profile_sethandle(user['token'],"Apple")
    
    # Checking handle
    profile = user_profile(user['token'], user['u_id'])
    assert(profile['handle_str'] == "Apple")
Exemple #8
0
def test_handle_too_long():
    global my_users
    data_delete()
    auth_register("*****@*****.**","password","Student","Citizen")
    user = auth_login("*****@*****.**",'password')
    
    # Changing user's handle
    with pytest.raises(ValueError):
        user_profile_sethandle(user['token'],"abcdefghijklmnopqrstuvwxyz")
    
    # Checking handle
    profile = user_profile(user['token'], user['u_id'])
    assert(profile['handle_str'] == "studentcitizen")
Exemple #9
0
def test_no_inputs_handle():
    global my_users
    data_delete()
    auth_register("*****@*****.**","password","Student","Citizen")
    user = auth_login("*****@*****.**",'password')
    
    # Changing user's handle
    with pytest.raises(AccessError):
        user_profile_sethandle("","")
    
    # Checking handle
    profile = user_profile(user['token'], user['u_id'])
    assert(profile['handle_str'] == "studentcitizen")
Exemple #10
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 #11
0
def test_correct_email():
    global my_users
    data_delete()
    auth_register("*****@*****.**","password","Student","Citizen")
    user = auth_login("*****@*****.**",'password')
    
    
    # Changing user's email
    user_profile_setemail(user['token'],'*****@*****.**')
    
    # Testing user_profile
    profile = user_profile(user['token'], user['u_id'])
    assert(profile['email'] == '*****@*****.**')
Exemple #12
0
def test_email_no_inputs():
    global my_users
    data_delete()
    auth_register("*****@*****.**","password","Student","Citizen")
    user = auth_login("*****@*****.**",'password')
    
    
     # Changing user's email
    with pytest.raises(AccessError):
        user_profile_setemail("","")
    
    # Checking email
    profile = user_profile(user['token'], user['u_id'])
    assert(profile['email'] == '*****@*****.**')
Exemple #13
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 #14
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')
Exemple #15
0
def test_email_used():
    global my_users
    data_delete()
    auth_register("*****@*****.**","password","Student","Citizen")
    user = auth_login("*****@*****.**",'password')
    
    
    # Creating user 2
    user2 = auth_register("*****@*****.**", "Lilyisthebest555", "John", "Smith")
    token2 = user2['token']
    
    # Changing user's email
    with pytest.raises(ValueError):
        user_profile_setemail(user['token'],"*****@*****.**")
    
    # Checking email
    profile = user_profile(user['token'], user['u_id'])
    assert(profile['email'] == '*****@*****.**')
Exemple #16
0
def test_nonEx_email():
    global my_users
    user = {"email": "*****@*****.**", "password": "******"}

    with pytest.raises(ValueError):
        auth_login(user["email"], user["password"])
Exemple #17
0
def test_wr_pasemail():
    global my_users
    user = {"email": "1234567", "password": "******"}

    with pytest.raises(ValueError):
        auth_login(user["email"], user["password"])
Exemple #18
0
def test_in_email():
    global my_users
    user = {"email": "*****@*****.**", "password": "******"}

    with pytest.raises(ValueError):
        auth_login(user["email"], user["password"])