Test for getWeeklyReport
This commit is contained in:
parent
c3ce25236f
commit
9f20d46fa6
2 changed files with 16 additions and 0 deletions
|
@ -37,13 +37,19 @@ func (gs *GState) SubmitWeeklyReport(c *fiber.Ctx) error {
|
||||||
// Handler for retrieving weekly report
|
// Handler for retrieving weekly report
|
||||||
func (gs *GState) GetWeeklyReport(c *fiber.Ctx) error {
|
func (gs *GState) GetWeeklyReport(c *fiber.Ctx) error {
|
||||||
// Extract the necessary parameters from the request
|
// Extract the necessary parameters from the request
|
||||||
|
println("GetWeeklyReport")
|
||||||
user := c.Locals("user").(*jwt.Token)
|
user := c.Locals("user").(*jwt.Token)
|
||||||
|
println(user)
|
||||||
claims := user.Claims.(jwt.MapClaims)
|
claims := user.Claims.(jwt.MapClaims)
|
||||||
|
println(claims)
|
||||||
username := claims["name"].(string)
|
username := claims["name"].(string)
|
||||||
|
println(username)
|
||||||
|
|
||||||
// Extract project name and week from query parameters
|
// Extract project name and week from query parameters
|
||||||
projectName := c.Query("projectName")
|
projectName := c.Query("projectName")
|
||||||
|
println(projectName)
|
||||||
week := c.Query("week")
|
week := c.Query("week")
|
||||||
|
println(week)
|
||||||
|
|
||||||
// Convert week to integer
|
// Convert week to integer
|
||||||
weekInt, err := strconv.Atoi(week)
|
weekInt, err := strconv.Atoi(week)
|
||||||
|
|
10
testing.py
10
testing.py
|
@ -21,6 +21,7 @@ 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"
|
submitReportPath = base_url + "/api/submitReport"
|
||||||
|
getWeeklyReportPath = base_url + "/api/getWeeklyReport"
|
||||||
|
|
||||||
|
|
||||||
# Posts the username and password to the register endpoint
|
# Posts the username and password to the register endpoint
|
||||||
|
@ -89,9 +90,18 @@ def test_submit_report():
|
||||||
assert response.status_code == 200, "Submit report failed"
|
assert response.status_code == 200, "Submit report failed"
|
||||||
print("Submit report successful")
|
print("Submit report successful")
|
||||||
|
|
||||||
|
def test_get_weekly_report():
|
||||||
|
token = login(username, "always_same").json()["token"]
|
||||||
|
response = requests.get(
|
||||||
|
getWeeklyReportPath,
|
||||||
|
headers={"Authorization": "Bearer " + token},
|
||||||
|
params={"username": username, "projectName": "report1", "week": 1}
|
||||||
|
)
|
||||||
|
print(response.text)
|
||||||
|
|
||||||
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()
|
test_submit_report()
|
||||||
|
test_get_weekly_report()
|
Loading…
Reference in a new issue