From 13720d633facc50570d95dcafde6821e1fb774b8 Mon Sep 17 00:00:00 2001 From: dDogge Date: Thu, 21 Mar 2024 00:41:40 +0100 Subject: [PATCH] Fixed test_change_user_name and added test_list_users_project once again --- testing.py | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/testing.py b/testing.py index dd1ce2d..6abd21d 100644 --- a/testing.py +++ b/testing.py @@ -394,12 +394,10 @@ def test_change_user_name(): headers={"Authorization": "Bearer " + admin_token}, ) - # Login as admin - # Change the user's name response = requests.put( getChangeUserNamePath, - json={"prevName": new_user, "newName": "new_username"}, + json={"prevName": new_user, "newName": randomString()}, headers={"Authorization": "Bearer " + admin_token}, ) @@ -407,6 +405,34 @@ def test_change_user_name(): assert response.status_code == 200, "Change user name failed" gprint("test_change_user_name successful") +def test_list_all_users_project(): + # Log in as a user who is a member of the project + admin_username = randomString() + admin_password = "admin_password2" + dprint( + "Registering with username: ", admin_username, " and password: ", admin_password + ) + response = requests.post( + registerPath, json={"username": admin_username, "password": admin_password} + ) + dprint(response.text) + + # Log in as the admin + admin_token = login(admin_username, admin_password).json()["token"] + response = requests.post( + promoteToAdminPath, + json={"username": admin_username}, + headers={"Authorization": "Bearer " + admin_token}, + ) + + # Make a request to list all users associated with the project + response = requests.get( + getUsersProjectPath + "/" + projectName, + headers={"Authorization": "Bearer " + admin_token}, + ) + assert response.status_code == 200, "List all users project failed" + gprint("test_list_all_users_project sucessful") + if __name__ == "__main__": test_get_user_projects() test_create_user() @@ -420,6 +446,6 @@ if __name__ == "__main__": test_get_weekly_reports_user() test_check_if_project_manager() test_ProjectRoleChange() - #test_list_all_users_project() test_ensure_manager_of_created_project() + test_list_all_users_project() test_change_user_name()