ChangeProjectName Handler + API

This commit is contained in:
al8763be 2024-04-17 21:31:47 +02:00
parent 6c4fe7bda3
commit 47d4bda99b
7 changed files with 166 additions and 2 deletions

View file

@ -37,8 +37,9 @@ promoteToPmPath = base_url + "/api/promoteToPm"
unsignReportPath = base_url + "/api/unsignReport"
deleteReportPath = base_url + "/api/deleteReport"
getStatisticsPath = base_url + "/api/getStatistics"
changeProjectNamePath = base_url + "/api/changeProjectName"
debug_output = False
debug_output = True
def gprint(*args, **kwargs):
@ -170,4 +171,12 @@ def getStatistics(token: string, projectName: string):
headers = {"Authorization": "Bearer " + token},
params={"projectName": projectName}
)
return response.json()
return response.json()
def changeProjectName(token: string, projectName: string, newProjectName: string):
response = requests.put(
changeProjectNamePath + "/" + projectName,
headers = {"Authorization": "Bearer " + token},
params={"newProjectName": newProjectName}
)
return response

View file

@ -666,8 +666,46 @@ def test_get_statistics():
assert stats["totalDevelopmentTime"] == 20, "Total development time is not correct"
gprint("test_get_statistics successful")
def test_project_name_change():
# Create admin
admin_username = randomString()
admin_password = randomString()
project_name = "project" + randomString()
token = register_and_login(admin_username, admin_password)
response = create_project(token, project_name)
assert response.status_code == 200, "Create project failed"
response = requests.get(
getUserProjectsPath + "/" + admin_username,
headers={"Authorization": "Bearer " + token},
)
dprint(response.json())
new_project_name = "new project name " + randomString()
dprint("Changing project name from ", project_name, " to ", new_project_name)
response = changeProjectName(token, project_name, new_project_name)
response = requests.get(
getUserProjectsPath + "/" + admin_username,
headers={"Authorization": "Bearer " + token},
)
dprint(response.json())
if (response.json()[0]["name"] != new_project_name):
assert False, "Project name change failed"
assert response.status_code == 200, "Project name change failed"
gprint("test_projectNameChange successful")
if __name__ == "__main__":
test_project_name_change();
test_delete_report()
test_unsign_report()
test_promote_to_manager()