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_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_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_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_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_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_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_20_users(): global my_users data_delete() for i in range(0,19): string = "st" + str(i) + "@unsw.edu.au" user = auth_register(string,"password","Studentabcde","Citizen") userDict = user_profile(user['token'], user['u_id']); handle = "studentabcdecitize" if i == 0: handle += "n" elif i >= 1 and i < 10: handle += "n" + str(i) else: handle += str(i) assert handle == userDict['handle_str']
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 user_profile_show(): token = request.args.get('token') u_id = request.args.get('u_id') try: returnDict = user_profile(token, int(u_id)) if returnDict is not None: return sendSuccess({ 'u_id' : returnDict['u_id'], 'email' : returnDict['email'], 'name_first' : returnDict['name_first'], 'name_last' : returnDict['name_last'], 'handle_str' : returnDict['handle_str'], 'profile_img_url' : returnDict['profile_img_url'] }) except ValueError as e: return sendError(400, "ValueError", e.args) except AccessError as a: return sendError(401, "AccessError", a.args)
def test_no_inputs_profile(): # Testing user_profile with pytest.raises(AccessError): user_profile("", "")