Test for getUserProjectsAdded
This commit is contained in:
parent
2cff1d55f9
commit
9056aafd2e
1 changed files with 17 additions and 11 deletions
28
testing.py
28
testing.py
|
@ -28,6 +28,21 @@ addUserToProjectPath = base_url + "/api/addUserToProject"
|
|||
promoteToAdminPath = base_url + "/api/promoteToAdmin"
|
||||
getUserProjectsPath = base_url + "/api/getUserProjects"
|
||||
|
||||
def test_get_user_projects():
|
||||
|
||||
print("Testing get user projects")
|
||||
loginResponse = login("user2", "123")
|
||||
# Check if the user is added to the project
|
||||
response = requests.get(
|
||||
getUserProjectsPath,
|
||||
json={"username": "user2"},
|
||||
headers={"Authorization": "Bearer " + loginResponse.json()["token"]},
|
||||
)
|
||||
print(response.text)
|
||||
print(response.json())
|
||||
assert response.status_code == 200, "Get user projects failed"
|
||||
print("got user projects successfully")
|
||||
|
||||
|
||||
# Posts the username and password to the register endpoint
|
||||
def register(username: string, password: string):
|
||||
|
@ -146,17 +161,7 @@ def test_add_user_to_project():
|
|||
|
||||
print(response.text)
|
||||
assert response.status_code == 200, "Add user to project failed"
|
||||
print("Add user to project successful")
|
||||
|
||||
# Check if the user is added to the project
|
||||
response = requests.get(
|
||||
getUserProjectsPath,
|
||||
json={"username": new_user},
|
||||
headers={"Authorization": "Bearer " + admin_token},
|
||||
)
|
||||
print(response.text)
|
||||
assert response.status_code == 200, "Get user projects failed"
|
||||
print("got user projects successfully")
|
||||
print("Add user to project successful")
|
||||
|
||||
# Test function to sign a report
|
||||
def test_sign_report():
|
||||
|
@ -235,6 +240,7 @@ def test_sign_report():
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_get_user_projects()
|
||||
test_create_user()
|
||||
test_login()
|
||||
test_add_project()
|
||||
|
|
Loading…
Reference in a new issue