def test_existing_e_mail_update(self): with app.test_request_context(): user1 = TEST_USERS[0] user2 = TEST_USERS[1] response = main.update_user_data(user1[0], user1[2], # Original user name and e-mail user1[0], user2[2], # New user name and email user1[1], user1[3], user1[4], "Not set", user1[5]) def correct_response(): return response["response"] == "E-Mail Exists" self.failIf(not correct_response())
def test_update_user_data(self): with app.test_request_context(): user = TEST_USERS[0] response = main.update_user_data(user[0], user[2], # Original user name and e-mail "new_user_name", "new_e_mail", "new_password", "new_country", "new_city", "new_location", "new_image") def correct_response(): # Checks that the data has been updated in the users table user_data1 = main.get_user_data("new_user_name") user_data2 = main.get_user_data("new_e_mail") scen_1 = user_data1["user_name"] == user_data2["user_name"] == "new_user_name" scen_2 = user_data1["e_mail"] == user_data2["e_mail"] == "new_e_mail" scen_3 = user_data1["country"] == user_data2["country"] == "new_country" scen_4 = user_data1["city"] == user_data2["city"] == "new_city" scen_5 = user_data1["location"] == user_data2["location"] == "new_location" scen_6 = user_data1["avatar_image"] == user_data2["avatar_image"] == "new_image" scen_7 = response["response"] == "Success" users_updated = scen_1 and scen_2 and scen_3 and scen_4 and scen_5 and scen_6 and scen_7 # Checks that the data has been updated in the ideas table # Since an idea by the user who's user name has been updated # had posted an idea, the function get_most_recent_idea returns # a non-empty list when using the new user name as parameter ideas_updated = db.get_most_recent_idea("new_user_name") != [] # Checks that the data has been updated in the messages table # Since the original user has sent a message, the return value # from get conversation using the new user name and the other # user's name has to return a non-empty list messages_updated = db.get_conversation("new_user_name", "TestUser2") != [] # Checks that the data has been updated in the comments table # The user who's name was changed posted a comment on the idea with id 2 comments_updated = False for comment in db.get_comments(2): if "new_user_name" in comment: comments_updated = True return users_updated and ideas_updated and messages_updated and comments_updated self.failIf(not correct_response())