Compare commits
No commits in common. "dbb2ff84e56ae60f0d1bba64e1487e0e7d605e02" and "b69f8d82ff43f440320eb74797b9f511f9f03613" have entirely different histories.
dbb2ff84e5
...
b69f8d82ff
3 changed files with 10 additions and 40 deletions
|
@ -267,14 +267,6 @@ func (gs *GState) SubmitWeeklyReport(c *fiber.Ctx) error {
|
||||||
return c.Status(400).SendString(err.Error())
|
return c.Status(400).SendString(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure all the fields of the report are valid
|
|
||||||
if report.Week < 1 || report.Week > 52 {
|
|
||||||
return c.Status(400).SendString("Invalid week number")
|
|
||||||
}
|
|
||||||
if report.DevelopmentTime < 0 || report.MeetingTime < 0 || report.AdminTime < 0 || report.OwnWorkTime < 0 || report.StudyTime < 0 || report.TestingTime < 0 {
|
|
||||||
return c.Status(400).SendString("Invalid time report")
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := gs.Db.AddWeeklyReport(report.ProjectName, username, report.Week, report.DevelopmentTime, report.MeetingTime, report.AdminTime, report.OwnWorkTime, report.StudyTime, report.TestingTime); err != nil {
|
if err := gs.Db.AddWeeklyReport(report.ProjectName, username, report.Week, report.DevelopmentTime, report.MeetingTime, report.AdminTime, report.OwnWorkTime, report.StudyTime, report.TestingTime); err != nil {
|
||||||
return c.Status(500).SendString(err.Error())
|
return c.Status(500).SendString(err.Error())
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,19 +3,19 @@ package types
|
||||||
// This is what should be submitted to the server, the username will be derived from the JWT token
|
// This is what should be submitted to the server, the username will be derived from the JWT token
|
||||||
type NewWeeklyReport struct {
|
type NewWeeklyReport struct {
|
||||||
// The name of the project, as it appears in the database
|
// The name of the project, as it appears in the database
|
||||||
ProjectName string `json:"projectName"`
|
ProjectName string
|
||||||
// The week number
|
// The week number
|
||||||
Week int `json:"week"`
|
Week int
|
||||||
// Total time spent on development
|
// Total time spent on development
|
||||||
DevelopmentTime int `json:"developmentTime"`
|
DevelopmentTime int
|
||||||
// Total time spent in meetings
|
// Total time spent in meetings
|
||||||
MeetingTime int `json:"meetingTime"`
|
MeetingTime int
|
||||||
// Total time spent on administrative tasks
|
// Total time spent on administrative tasks
|
||||||
AdminTime int `json:"adminTime"`
|
AdminTime int
|
||||||
// Total time spent on personal projects
|
// Total time spent on personal projects
|
||||||
OwnWorkTime int `json:"ownWorkTime"`
|
OwnWorkTime int
|
||||||
// Total time spent on studying
|
// Total time spent on studying
|
||||||
StudyTime int `json:"studyTime"`
|
StudyTime int
|
||||||
// Total time spent on testing
|
// Total time spent on testing
|
||||||
TestingTime int `json:"testingTime"`
|
TestingTime int
|
||||||
}
|
}
|
||||||
|
|
26
testing.py
26
testing.py
|
@ -11,7 +11,7 @@ def randomString(len=10):
|
||||||
|
|
||||||
# Defined once per test run
|
# Defined once per test run
|
||||||
username = randomString()
|
username = randomString()
|
||||||
projectName = randomString()
|
token = None
|
||||||
|
|
||||||
# The base URL of the API
|
# The base URL of the API
|
||||||
base_url = "http://localhost:8080"
|
base_url = "http://localhost:8080"
|
||||||
|
@ -20,7 +20,6 @@ base_url = "http://localhost:8080"
|
||||||
registerPath = base_url + "/api/register"
|
registerPath = base_url + "/api/register"
|
||||||
loginPath = base_url + "/api/login"
|
loginPath = base_url + "/api/login"
|
||||||
addProjectPath = base_url + "/api/project"
|
addProjectPath = base_url + "/api/project"
|
||||||
submitReportPath = base_url + "/api/submitReport"
|
|
||||||
|
|
||||||
|
|
||||||
# Posts the username and password to the register endpoint
|
# Posts the username and password to the register endpoint
|
||||||
|
@ -59,6 +58,7 @@ def test_create_user():
|
||||||
def test_add_project():
|
def test_add_project():
|
||||||
loginResponse = login(username, "always_same")
|
loginResponse = login(username, "always_same")
|
||||||
token = loginResponse.json()["token"]
|
token = loginResponse.json()["token"]
|
||||||
|
projectName = randomString()
|
||||||
response = requests.post(
|
response = requests.post(
|
||||||
addProjectPath,
|
addProjectPath,
|
||||||
json={"name": projectName, "description": "This is a project"},
|
json={"name": projectName, "description": "This is a project"},
|
||||||
|
@ -69,29 +69,7 @@ def test_add_project():
|
||||||
print("Add project successful")
|
print("Add project successful")
|
||||||
|
|
||||||
|
|
||||||
def test_submit_report():
|
|
||||||
token = login(username, "always_same").json()["token"]
|
|
||||||
response = requests.post(
|
|
||||||
submitReportPath,
|
|
||||||
json={
|
|
||||||
"projectName": "report1",
|
|
||||||
"week": 1,
|
|
||||||
"developmentTime": 10,
|
|
||||||
"meetingTime": 5,
|
|
||||||
"adminTime": 5,
|
|
||||||
"ownWorkTime": 10,
|
|
||||||
"studyTime": 10,
|
|
||||||
"testingTime": 10,
|
|
||||||
},
|
|
||||||
headers={"Authorization": "Bearer " + token},
|
|
||||||
)
|
|
||||||
print(response.text)
|
|
||||||
assert response.status_code == 200, "Submit report failed"
|
|
||||||
print("Submit report successful")
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
test_create_user()
|
test_create_user()
|
||||||
test_login()
|
test_login()
|
||||||
test_add_project()
|
test_add_project()
|
||||||
test_submit_report()
|
|
||||||
|
|
Loading…
Reference in a new issue