DeleteProject Handler + API function, ber till gud att denna funkar first try
This commit is contained in:
parent
a5e3d4259d
commit
67723bfccc
7 changed files with 172 additions and 0 deletions
|
@ -35,6 +35,7 @@ getUpdateWeeklyReportPath = base_url + "/api/updateWeeklyReport"
|
|||
removeProjectPath = base_url + "/api/removeProject"
|
||||
promoteToPmPath = base_url + "/api/promoteToPm"
|
||||
unsignReportPath = base_url + "/api/unsignReport"
|
||||
deleteReportPath = base_url + "/api/deleteReport"
|
||||
|
||||
debug_output = False
|
||||
|
||||
|
@ -156,3 +157,8 @@ def unsignReport(project_manager_token: string, report_id: int):
|
|||
unsignReportPath + "/" + str(report_id),
|
||||
headers={"Authorization": "Bearer " + project_manager_token},
|
||||
)
|
||||
|
||||
def deleteReport(report_id: int):
|
||||
return requests.delete(
|
||||
deleteReportPath + "/" + str(report_id),
|
||||
)
|
||||
|
|
|
@ -557,8 +557,74 @@ def test_promote_to_manager():
|
|||
response = promoteToManager(pm_token, member_user, project_name)
|
||||
assert response.status_code == 200, "Promote to manager failed"
|
||||
|
||||
def test_delete_report():
|
||||
# Create admin
|
||||
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},
|
||||
)
|
||||
|
||||
# Create a new project
|
||||
new_project = randomString()
|
||||
response = requests.post(
|
||||
addProjectPath,
|
||||
json={"name": new_project, "description": "This is a project"},
|
||||
headers={"Authorization": "Bearer " + admin_token},
|
||||
)
|
||||
assert response.status_code == 200, "Add project failed"
|
||||
|
||||
# Create a new report
|
||||
new_report = {
|
||||
"projectName": new_project,
|
||||
"week": 1,
|
||||
"developmentTime": 10,
|
||||
"meetingTime": 5,
|
||||
"adminTime": 5,
|
||||
"ownWorkTime": 10,
|
||||
"studyTime": 10,
|
||||
"testingTime": 10,
|
||||
}
|
||||
response = submitReport(admin_token, new_report);
|
||||
assert response.status_code == 200, "Submit report failed"
|
||||
|
||||
# Get the report ID
|
||||
report_id = getReport(admin_token, admin_username, new_project)["reportId"]
|
||||
assert report_id != None, "Get report failed"
|
||||
|
||||
# Delete the report
|
||||
response = requests.delete(
|
||||
deleteReportPath + "/" + str(report_id),
|
||||
headers={"Authorization": "Bearer " + admin_token},
|
||||
)
|
||||
assert response.status_code == 200, "Delete report failed"
|
||||
|
||||
# Check if the report was deleted
|
||||
response = requests.get(
|
||||
getWeeklyReportPath,
|
||||
headers={"Authorization": "Bearer " + admin_token},
|
||||
params={"username": admin_username, "projectName": new_project, "week": 1},
|
||||
)
|
||||
assert response.status_code == 500, "Report was not deleted"
|
||||
|
||||
gprint("test_delete_report successful")
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_delete_report()
|
||||
test_unsign_report()
|
||||
test_promote_to_manager()
|
||||
test_remove_project()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue