unsignReport handler + API function
This commit is contained in:
parent
f57c445ead
commit
a5e3d4259d
7 changed files with 264 additions and 0 deletions
|
@ -34,6 +34,7 @@ getChangeUserNamePath = base_url + "/api/changeUserName"
|
|||
getUpdateWeeklyReportPath = base_url + "/api/updateWeeklyReport"
|
||||
removeProjectPath = base_url + "/api/removeProject"
|
||||
promoteToPmPath = base_url + "/api/promoteToPm"
|
||||
unsignReportPath = base_url + "/api/unsignReport"
|
||||
|
||||
debug_output = False
|
||||
|
||||
|
@ -149,3 +150,9 @@ def signReport(project_manager_token: string, report_id: int):
|
|||
signReportPath + "/" + str(report_id),
|
||||
headers={"Authorization": "Bearer " + project_manager_token},
|
||||
)
|
||||
|
||||
def unsignReport(project_manager_token: string, report_id: int):
|
||||
return requests.put(
|
||||
unsignReportPath + "/" + str(report_id),
|
||||
headers={"Authorization": "Bearer " + project_manager_token},
|
||||
)
|
||||
|
|
|
@ -215,6 +215,68 @@ def test_sign_report():
|
|||
assert report_id != None, "Get report failed"
|
||||
gprint("test_sign_report successful")
|
||||
|
||||
# Test function to unsign a report
|
||||
def test_unsign_report():
|
||||
# Pm user
|
||||
pm_username = "pm" + randomString()
|
||||
pm_password = "admin_password2"
|
||||
|
||||
# User to add
|
||||
member_user = "member" + randomString()
|
||||
member_passwd = "password"
|
||||
|
||||
# Name of the project to be created
|
||||
project_name = "project" + randomString()
|
||||
|
||||
# Register and get the tokens for both users
|
||||
pm_token = register_and_login(pm_username, pm_password)
|
||||
member_token = register_and_login(member_user, member_passwd)
|
||||
|
||||
# Create the project
|
||||
response = create_project(pm_token, project_name)
|
||||
assert response.status_code == 200, "Create project failed"
|
||||
|
||||
# Add the user to the project
|
||||
response = addToProject(pm_token, member_user, project_name)
|
||||
|
||||
# Submit a report for the project
|
||||
response = submitReport(
|
||||
member_token,
|
||||
{
|
||||
"projectName": project_name,
|
||||
"week": 1,
|
||||
"developmentTime": 10,
|
||||
"meetingTime": 5,
|
||||
"adminTime": 5,
|
||||
"ownWorkTime": 10,
|
||||
"studyTime": 10,
|
||||
"testingTime": 10,
|
||||
},
|
||||
)
|
||||
assert response.status_code == 200, "Submit report failed"
|
||||
|
||||
# Retrieve the report ID
|
||||
report_id = getReport(member_token, member_user, project_name)["reportId"]
|
||||
|
||||
# Sign the report as the project manager
|
||||
response = signReport(pm_token, report_id)
|
||||
assert response.status_code == 200, "Sign report failed"
|
||||
dprint("Sign report successful")
|
||||
|
||||
# Retrieve the report ID again for confirmation
|
||||
report_id = getReport(member_token, member_user, project_name)["reportId"]
|
||||
assert report_id != None, "Get report failed"
|
||||
|
||||
# Unsign the report as the project manager
|
||||
response = unsignReport(pm_token, report_id)
|
||||
assert response.status_code == 200, "Unsign report failed"
|
||||
dprint("Unsign report successful")
|
||||
|
||||
# Retrieve the report ID again for confirmation
|
||||
report_id = getReport(member_token, member_user, project_name)["reportId"]
|
||||
assert report_id != None, "Get report failed"
|
||||
gprint("test_unsign_report successful")
|
||||
|
||||
|
||||
# Test function to get weekly reports for a user in a project
|
||||
def test_get_all_weekly_reports():
|
||||
|
@ -497,6 +559,7 @@ def test_promote_to_manager():
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_unsign_report()
|
||||
test_promote_to_manager()
|
||||
test_remove_project()
|
||||
test_get_user_projects()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue