|
@ -7,6 +7,35 @@ from flask.testing import FlaskClient |
|
|
from tests.conftest import AuthActions |
|
|
from tests.conftest import AuthActions |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_get_users_happy_path(auth: AuthActions, client: FlaskClient): |
|
|
|
|
|
auth.login() |
|
|
|
|
|
auth_header = auth.get_authorization_header_token() |
|
|
|
|
|
result = client.get( |
|
|
|
|
|
'/user', |
|
|
|
|
|
headers={ |
|
|
|
|
|
auth_header[0]: auth_header[1] |
|
|
|
|
|
}) |
|
|
|
|
|
assert 200 == result.status_code |
|
|
|
|
|
assert result.json is not None |
|
|
|
|
|
assert result.json['page'] == 1 |
|
|
|
|
|
assert result.json['lastPage'] == 1 |
|
|
|
|
|
assert result.json['count'] == 1 |
|
|
|
|
|
assert result.json['totalCount'] == 1 |
|
|
|
|
|
assert result.json['items'][0]['name'] == auth.username |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_get_users_nonexistent_page(auth: AuthActions, client: FlaskClient): |
|
|
|
|
|
auth.login() |
|
|
|
|
|
auth_header = auth.get_authorization_header_token() |
|
|
|
|
|
result = client.get( |
|
|
|
|
|
'/user?page=2', |
|
|
|
|
|
headers={ |
|
|
|
|
|
auth_header[0]: auth_header[1] |
|
|
|
|
|
}) |
|
|
|
|
|
assert 404 == result.status_code |
|
|
|
|
|
assert result.json is not None |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_get_user_happy_path(auth: AuthActions, client: FlaskClient): |
|
|
def test_get_user_happy_path(auth: AuthActions, client: FlaskClient): |
|
|
auth.login() |
|
|
auth.login() |
|
|
auth_header = auth.get_authorization_header_token() |
|
|
auth_header = auth.get_authorization_header_token() |
|
@ -51,7 +80,7 @@ def test_register_user_happy_path(auth: AuthActions, client: FlaskClient): |
|
|
auth.login() |
|
|
auth.login() |
|
|
auth_header = auth.get_authorization_header_token() |
|
|
auth_header = auth.get_authorization_header_token() |
|
|
result = client.post( |
|
|
result = client.post( |
|
|
'/user/', |
|
|
|
|
|
|
|
|
'/user', |
|
|
data=json.dumps({ |
|
|
data=json.dumps({ |
|
|
'name': 'test_registered_user' |
|
|
'name': 'test_registered_user' |
|
|
}), |
|
|
}), |
|
@ -69,7 +98,7 @@ def test_register_user_invalid_password( |
|
|
auth.login() |
|
|
auth.login() |
|
|
auth_header = auth.get_authorization_header_token() |
|
|
auth_header = auth.get_authorization_header_token() |
|
|
result = client.post( |
|
|
result = client.post( |
|
|
'/user/', |
|
|
|
|
|
|
|
|
'/user', |
|
|
data=json.dumps({ |
|
|
data=json.dumps({ |
|
|
'name': 'test_registered_user', |
|
|
'name': 'test_registered_user', |
|
|
'password': '' |
|
|
'password': '' |
|
@ -87,7 +116,7 @@ def test_register_user_twice_failure(auth: AuthActions, client: FlaskClient): |
|
|
auth.login() |
|
|
auth.login() |
|
|
auth_header = auth.get_authorization_header_token() |
|
|
auth_header = auth.get_authorization_header_token() |
|
|
result1 = client.post( |
|
|
result1 = client.post( |
|
|
'/user/', |
|
|
|
|
|
|
|
|
'/user', |
|
|
data=json.dumps({ |
|
|
data=json.dumps({ |
|
|
'name': 'test_registered_user' |
|
|
'name': 'test_registered_user' |
|
|
}), |
|
|
}), |
|
@ -96,7 +125,7 @@ def test_register_user_twice_failure(auth: AuthActions, client: FlaskClient): |
|
|
'Content-Type': 'application/json' |
|
|
'Content-Type': 'application/json' |
|
|
}) |
|
|
}) |
|
|
result2 = client.post( |
|
|
result2 = client.post( |
|
|
'/user/', |
|
|
|
|
|
|
|
|
'/user', |
|
|
data=json.dumps({ |
|
|
data=json.dumps({ |
|
|
'name': 'test_registered_user' |
|
|
'name': 'test_registered_user' |
|
|
}), |
|
|
}), |
|
@ -116,7 +145,7 @@ def test_delete_user_happy_path(auth: AuthActions, client: FlaskClient): |
|
|
auth.login() |
|
|
auth.login() |
|
|
auth_header = auth.get_authorization_header_token() |
|
|
auth_header = auth.get_authorization_header_token() |
|
|
result1 = client.post( |
|
|
result1 = client.post( |
|
|
'/user/', |
|
|
|
|
|
|
|
|
'/user', |
|
|
data=json.dumps({ |
|
|
data=json.dumps({ |
|
|
'name': 'test_registered_user' |
|
|
'name': 'test_registered_user' |
|
|
}), |
|
|
}), |
|
|