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]
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
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')
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")
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)
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')
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")
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")
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")
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')
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'] == '*****@*****.**')
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'] == '*****@*****.**')
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')
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')
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'] == '*****@*****.**')
def test_nonEx_email(): global my_users user = {"email": "*****@*****.**", "password": "******"} with pytest.raises(ValueError): auth_login(user["email"], user["password"])
def test_wr_pasemail(): global my_users user = {"email": "1234567", "password": "******"} with pytest.raises(ValueError): auth_login(user["email"], user["password"])
def test_in_email(): global my_users user = {"email": "*****@*****.**", "password": "******"} with pytest.raises(ValueError): auth_login(user["email"], user["password"])