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
|
# Defined once per test run
|
||||||
username = randomString()
|
username = randomString()
|
||||||
token = None
|
projectName = randomString()
|
||||||
|
|
||||||
# The base URL of the API
|
# The base URL of the API
|
||||||
base_url = "http://localhost:8080"
|
base_url = "http://localhost:8080"
|
||||||
|
@ -20,6 +20,7 @@ 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
|
||||||
|
@ -58,7 +59,6 @@ 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,7 +69,29 @@ 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