1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-25 14:34:19 +00:00

aggiunta fixture header

This commit is contained in:
FlaviaC-uni 2021-05-08 16:36:50 +02:00
parent 0ce4ec6993
commit e294734d86
3 changed files with 17 additions and 7 deletions

View file

@ -4,4 +4,4 @@ Pytest configuration file.
Import global fixtures here.
"""
from fixtures.flask_client import flask_client, access_token
from fixtures.flask_client import flask_client, access_token, headers

View file

@ -50,3 +50,9 @@ def access_token(flask_client):
data = response.json["data"]
assert "access_token" in data
return data["access_token"]
@pytest.fixture()
def headers(access_token):
headers = {'Authorization': f"Bearer {access_token}"}
return headers

View file

@ -1,20 +1,24 @@
from flask.testing import Client
class TestUserGet:
def test_for_success(self, flask_client: Client, access_token: str):
r = flask_client.get(f'/api/v1/users/admin@admin.com', headers={'Authorization': f"Bearer {access_token}"})
def test_for_success(self, flask_client: Client, headers):
r = flask_client.get(f'/api/v1/users/admin@admin.com', headers=headers)
assert b'success' in r.data
class TestUserAdd:
def test_for_success(self, flask_client: Client, access_token: str):
r = flask_client.post(f'/api/v1/users/', headers={'Authorization': f"Bearer {access_token}"},
def test_for_success(self, flask_client: Client, headers):
r = flask_client.post(f'/api/v1/users/', headers=headers,
json={'email': 'utente_test@nest.com', 'password': 'password', 'username': 'utente_test'})
assert b'success' in r.data
class TestUserDelete:
def test_for_success(self, flask_client: Client, access_token: str):
r = flask_client.delete(f'/api/v1/users/utente_test@nest.com', headers={'Authorization': f"Bearer {access_token}"})
def test_for_success(self, flask_client: Client, headers):
r = flask_client.delete(f'/api/v1/users/utente_test@nest.com', headers=headers)
assert b'success' in r.data