From dbb2ff84e56ae60f0d1bba64e1487e0e7d605e02 Mon Sep 17 00:00:00 2001 From: Imbus <> Date: Sun, 17 Mar 2024 04:16:54 +0100 Subject: [PATCH] WeeklyReport testing --- testing.py | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/testing.py b/testing.py index ff9534f..d2c64fe 100644 --- a/testing.py +++ b/testing.py @@ -11,7 +11,7 @@ def randomString(len=10): # Defined once per test run username = randomString() -token = None +projectName = randomString() # The base URL of the API base_url = "http://localhost:8080" @@ -20,6 +20,7 @@ base_url = "http://localhost:8080" registerPath = base_url + "/api/register" loginPath = base_url + "/api/login" addProjectPath = base_url + "/api/project" +submitReportPath = base_url + "/api/submitReport" # Posts the username and password to the register endpoint @@ -58,7 +59,6 @@ def test_create_user(): def test_add_project(): loginResponse = login(username, "always_same") token = loginResponse.json()["token"] - projectName = randomString() response = requests.post( addProjectPath, json={"name": projectName, "description": "This is a project"}, @@ -69,7 +69,29 @@ def test_add_project(): 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__": test_create_user() test_login() test_add_project() + test_submit_report()