WeeklyReport testing
This commit is contained in:
parent
0d053add5e
commit
dbb2ff84e5
1 changed files with 24 additions and 2 deletions
26
testing.py
26
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()
|
||||
|
|
Loading…
Reference in a new issue