GetUnsignedReports
This commit is contained in:
parent
dea802bd91
commit
f6dcdcc376
4 changed files with 15 additions and 44 deletions
|
@ -481,6 +481,11 @@ func TestGetUnsignedWeeklyReports(t *testing.T) {
|
|||
t.Error("AddUser failed:", err)
|
||||
}
|
||||
|
||||
err = db.AddUser("testuser1", "password")
|
||||
if err != nil {
|
||||
t.Error("AddUser failed:", err)
|
||||
}
|
||||
|
||||
err = db.AddProject("testproject", "description", "testuser")
|
||||
if err != nil {
|
||||
t.Error("AddProject failed:", err)
|
||||
|
@ -491,6 +496,11 @@ func TestGetUnsignedWeeklyReports(t *testing.T) {
|
|||
t.Error("AddWeeklyReport failed:", err)
|
||||
}
|
||||
|
||||
err = db.AddWeeklyReport("testproject", "testuser1", 1, 1, 1, 1, 1, 1, 1)
|
||||
if err != nil {
|
||||
t.Error("AddWeeklyReport failed:", err)
|
||||
}
|
||||
|
||||
reports, err := db.GetUnsignedWeeklyReports("testproject")
|
||||
if err != nil {
|
||||
t.Error("GetUnsignedWeeklyReports failed:", err)
|
||||
|
|
|
@ -122,7 +122,7 @@ func (gs *GState) GetUnsignedReports(c *fiber.Ctx) error {
|
|||
projectManagerUsername := claims["name"].(string)
|
||||
|
||||
// Extract project name and week from query parameters
|
||||
projectName := c.Query("projectName")
|
||||
projectName := c.Params("projectName")
|
||||
|
||||
log.Info("Getting unsigned reports for")
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ func main() {
|
|||
server.Get("/api/project/:projectId", gs.GetProject)
|
||||
server.Get("/api/project/getAllUsers", gs.GetAllUsersProject)
|
||||
server.Get("/api/getWeeklyReport", gs.GetWeeklyReport)
|
||||
server.Get("/api/getUnsignedReports", gs.GetUnsignedReports)
|
||||
server.Get("/api/getUnsignedReports/:projectName", gs.GetUnsignedReports)
|
||||
server.Post("/api/signReport", gs.SignReport)
|
||||
server.Put("/api/addUserToProject", gs.AddUserToProjectHandler)
|
||||
server.Put("/api/changeUserName", gs.ChangeUserName)
|
||||
|
|
45
testing.py
45
testing.py
|
@ -2,7 +2,7 @@ import requests
|
|||
import string
|
||||
import random
|
||||
|
||||
debug_output = False
|
||||
debug_output = True
|
||||
|
||||
def gprint(*args, **kwargs):
|
||||
print("\033[92m", *args, "\033[00m", **kwargs)
|
||||
|
@ -41,7 +41,7 @@ getWeeklyReportsUserPath = base_url + "/api/getWeeklyReportsUser"
|
|||
checkIfProjectManagerPath = base_url + "/api/checkIfProjectManager"
|
||||
ProjectRoleChangePath = base_url + "/api/ProjectRoleChange"
|
||||
getUsersProjectPath = base_url + "/api/getUsersProject"
|
||||
getUsignedReportsPath = base_url + "/api/getUsignedReports"
|
||||
getUnsignedReportsPath = base_url + "/api/getUnsignedReports"
|
||||
|
||||
#ta bort auth i handlern för att få testet att gå igenom
|
||||
def test_ProjectRoleChange():
|
||||
|
@ -330,45 +330,6 @@ def test_get_weekly_reports_user():
|
|||
assert response.status_code == 200, "Get weekly reports for user failed"
|
||||
gprint("test_get_weekly_reports_user successful")
|
||||
|
||||
def test_get_usigned_reports():
|
||||
# Log in as the user
|
||||
|
||||
token = login(username, "always_same").json()["token"]
|
||||
response = requests.post(
|
||||
submitReportPath,
|
||||
json={
|
||||
"projectName": projectName,
|
||||
"week": 3,
|
||||
"developmentTime": 10,
|
||||
"meetingTime": 5,
|
||||
"adminTime": 5,
|
||||
"ownWorkTime": 10,
|
||||
"studyTime": 10,
|
||||
"testingTime": 10,
|
||||
},
|
||||
headers={"Authorization": "Bearer " + token},
|
||||
)
|
||||
dprint(response.text)
|
||||
assert response.status_code == 200, "Submit report failed"
|
||||
|
||||
|
||||
# Get weekly reports for the user in the project
|
||||
response = requests.get(
|
||||
getWeeklyReportsUserPath + "/" + projectName,
|
||||
headers={"Authorization": "Bearer " + token},
|
||||
)
|
||||
|
||||
dprint(response.text)
|
||||
assert response.status_code == 200, "Get weekly reports for user failed"
|
||||
|
||||
response = requests.get(
|
||||
getUsignedReportsPath + "/" + projectName,
|
||||
headers={"Authorization": "Bearer " + token},
|
||||
)
|
||||
dprint(response.text)
|
||||
assert response.status_code == 200, "Get unsigned reports for user failed"
|
||||
gprint("test_get_usigned_reports successful")
|
||||
|
||||
|
||||
|
||||
# Test function to check if a user is a project manager
|
||||
|
@ -411,7 +372,6 @@ def test_ensure_manager_of_created_project():
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_get_usigned_reports()
|
||||
test_get_user_projects()
|
||||
test_create_user()
|
||||
test_login()
|
||||
|
@ -426,3 +386,4 @@ if __name__ == "__main__":
|
|||
test_ProjectRoleChange()
|
||||
#test_list_all_users_project()
|
||||
test_ensure_manager_of_created_project()
|
||||
test_get_unsigned_reports()
|
||||
|
|
Loading…
Reference in a new issue