Better test feedback in python script
This commit is contained in:
parent
7e4e35f597
commit
5bcca0202b
1 changed files with 14 additions and 5 deletions
19
testing.py
19
testing.py
|
@ -4,6 +4,11 @@ import random
|
|||
|
||||
debug_output = False
|
||||
|
||||
def gprint(*args, **kwargs):
|
||||
print("\033[92m", *args, "\033[00m", **kwargs)
|
||||
|
||||
print("Running Tests...")
|
||||
|
||||
def dprint(*args, **kwargs):
|
||||
if debug_output:
|
||||
print(*args, **kwargs)
|
||||
|
@ -47,7 +52,7 @@ def test_get_user_projects():
|
|||
dprint(response.text)
|
||||
dprint(response.json())
|
||||
assert response.status_code == 200, "Get user projects failed"
|
||||
dprint("got user projects successfully")
|
||||
gprint("test_get_user_projects successful")
|
||||
|
||||
|
||||
# Posts the username and password to the register endpoint
|
||||
|
@ -75,6 +80,7 @@ def test_login():
|
|||
response = login(username, "always_same")
|
||||
assert response.status_code == 200, "Login failed"
|
||||
dprint("Login successful")
|
||||
gprint("test_login successful")
|
||||
return response.json()["token"]
|
||||
|
||||
|
||||
|
@ -82,7 +88,7 @@ def test_login():
|
|||
def test_create_user():
|
||||
response = register(username, "always_same")
|
||||
assert response.status_code == 200, "Registration failed"
|
||||
dprint("Registration successful")
|
||||
gprint("test_create_user successful")
|
||||
|
||||
# Test function to add a project
|
||||
def test_add_project():
|
||||
|
@ -95,7 +101,7 @@ def test_add_project():
|
|||
)
|
||||
dprint(response.text)
|
||||
assert response.status_code == 200, "Add project failed"
|
||||
dprint("Add project successful")
|
||||
gprint("test_add_project successful")
|
||||
|
||||
# Test function to submit a report
|
||||
def test_submit_report():
|
||||
|
@ -116,7 +122,7 @@ def test_submit_report():
|
|||
)
|
||||
dprint(response.text)
|
||||
assert response.status_code == 200, "Submit report failed"
|
||||
dprint("Submit report successful")
|
||||
gprint("test_submit_report successful")
|
||||
|
||||
# Test function to get a weekly report
|
||||
def test_get_weekly_report():
|
||||
|
@ -128,6 +134,7 @@ def test_get_weekly_report():
|
|||
)
|
||||
dprint(response.text)
|
||||
assert response.status_code == 200, "Get weekly report failed"
|
||||
gprint("test_get_weekly_report successful")
|
||||
|
||||
|
||||
# Tests getting a project by id
|
||||
|
@ -139,6 +146,7 @@ def test_get_project():
|
|||
)
|
||||
dprint(response.text)
|
||||
assert response.status_code == 200, "Get project failed"
|
||||
gprint("test_get_project successful")
|
||||
|
||||
|
||||
# Test function to add a user to a project
|
||||
|
@ -177,7 +185,7 @@ def test_add_user_to_project():
|
|||
|
||||
dprint(response.text)
|
||||
assert response.status_code == 200, "Add user to project failed"
|
||||
dprint("Add user to project successful")
|
||||
gprint("test_add_user_to_project successful")
|
||||
|
||||
# Test function to sign a report
|
||||
def test_sign_report():
|
||||
|
@ -265,6 +273,7 @@ def test_sign_report():
|
|||
params={"username": username, "projectName": projectName, "week": 1},
|
||||
)
|
||||
dprint(response.text)
|
||||
gprint("test_sign_report successful")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
Loading…
Add table
Reference in a new issue