getStatistics handler, db-interface and ts API
This commit is contained in:
parent
2d2b63938c
commit
fe9d5f74bb
8 changed files with 188 additions and 1 deletions
|
@ -36,6 +36,7 @@ removeProjectPath = base_url + "/api/removeProject"
|
|||
promoteToPmPath = base_url + "/api/promoteToPm"
|
||||
unsignReportPath = base_url + "/api/unsignReport"
|
||||
deleteReportPath = base_url + "/api/deleteReport"
|
||||
getStatisticsPath = base_url + "/api/getStatistics"
|
||||
|
||||
debug_output = False
|
||||
|
||||
|
@ -162,3 +163,11 @@ def deleteReport(report_id: int):
|
|||
return requests.delete(
|
||||
deleteReportPath + "/" + str(report_id),
|
||||
)
|
||||
|
||||
def getStatistics(token: string, projectName: string):
|
||||
response = requests.get(
|
||||
getStatisticsPath,
|
||||
headers = {"Authorization": "Bearer " + token},
|
||||
params={"projectName": projectName}
|
||||
)
|
||||
return response.json()
|
|
@ -625,6 +625,46 @@ def test_delete_report():
|
|||
|
||||
gprint("test_delete_report successful")
|
||||
|
||||
def test_get_statistics():
|
||||
# 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 = submitReport(token, {
|
||||
"projectName": project_name,
|
||||
"week": 1,
|
||||
"developmentTime": 10,
|
||||
"meetingTime": 5,
|
||||
"adminTime": 5,
|
||||
"ownWorkTime": 10,
|
||||
"studyTime": 10,
|
||||
"testingTime": 10,
|
||||
})
|
||||
|
||||
response = submitReport(token, {
|
||||
"projectName": project_name,
|
||||
"week": 2,
|
||||
"developmentTime": 10,
|
||||
"meetingTime": 5,
|
||||
"adminTime": 5,
|
||||
"ownWorkTime": 10,
|
||||
"studyTime": 10,
|
||||
"testingTime": 10,
|
||||
})
|
||||
|
||||
assert response.status_code == 200, "Submit report failed"
|
||||
|
||||
stats = getStatistics(token, project_name)
|
||||
|
||||
assert stats["totalDevelopmentTime"] == 20, "Total development time is not correct"
|
||||
gprint("test_get_statistics successful")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -650,3 +690,4 @@ if __name__ == "__main__":
|
|||
test_change_user_name()
|
||||
test_update_weekly_report()
|
||||
test_get_other_users_report_as_pm()
|
||||
test_get_statistics()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue