mirror of
https://github.com/pds-nest/nest.git
synced 2024-11-22 04:54:18 +00:00
test user completati, un paio funzionano in maniera misteriosa
This commit is contained in:
parent
47d08da877
commit
2824ac71e2
3 changed files with 19 additions and 4 deletions
|
@ -4,4 +4,6 @@ Pytest configuration file.
|
||||||
Import global fixtures here.
|
Import global fixtures here.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from fixtures.flask_client import flask_client, admin_access_token, admin_headers, user_access_token, user_headers
|
from fixtures.flask_client import flask_client, admin_access_token, admin_headers, user_access_token, user_headers, user_create
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
import pytest
|
import pytest
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
import requests
|
||||||
|
|
||||||
from nest_backend.app import app
|
from nest_backend.app import app
|
||||||
from nest_backend.gestione import gen_password
|
from nest_backend.gestione import gen_password
|
||||||
from nest_backend.database import ext
|
from nest_backend.database import ext
|
||||||
|
@ -79,3 +82,11 @@ def user_headers(user_access_token):
|
||||||
return user_headers
|
return user_headers
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture()
|
||||||
|
def user_create(admin_headers, flask_client):
|
||||||
|
r = flask_client.post(f'/api/v1/users/', headers=admin_headers, json={
|
||||||
|
'email': 'utente_test@nest.com',
|
||||||
|
'password': 'password',
|
||||||
|
'username': 'utente_test'
|
||||||
|
})
|
||||||
|
|
||||||
|
|
|
@ -11,12 +11,13 @@ class TestUserGet:
|
||||||
|
|
||||||
# ritorna i dati di tutti gli utenti registrati
|
# ritorna i dati di tutti gli utenti registrati
|
||||||
class TestUserGetAll:
|
class TestUserGetAll:
|
||||||
def test_for_success(self, flask_client: Client, admin_headers):
|
def test_for_success(self, flask_client: Client, admin_headers, user_create):
|
||||||
r = flask_client.get(f'/api/v1/users/', headers=admin_headers)
|
r = flask_client.get(f'/api/v1/users/', headers=admin_headers)
|
||||||
assert b'success' in r.data
|
assert b'success' in r.data
|
||||||
|
|
||||||
# FIXME AssertionError in flask_client at line 63. Il test non riesce ad andare a buon fine
|
# FIXME AssertionError in flask_client at line 63. Il test non riesce ad andare a buon fine
|
||||||
def test_for_failure(self, flask_client: Client, user_headers):
|
def test_for_failure(self, flask_client: Client, user_headers):
|
||||||
|
|
||||||
r = flask_client.get(f'/api/v1/users/', headers=user_headers)
|
r = flask_client.get(f'/api/v1/users/', headers=user_headers)
|
||||||
assert b'failure' in r.data
|
assert b'failure' in r.data
|
||||||
|
|
||||||
|
@ -24,7 +25,7 @@ class TestUserGetAll:
|
||||||
class TestUserAdd:
|
class TestUserAdd:
|
||||||
def test_for_success(self, flask_client: Client, admin_headers):
|
def test_for_success(self, flask_client: Client, admin_headers):
|
||||||
r = flask_client.post(f'/api/v1/users/', headers=admin_headers, json={
|
r = flask_client.post(f'/api/v1/users/', headers=admin_headers, json={
|
||||||
'email': 'utente_test@nest.com',
|
'email': 'utente1_test@nest.com',
|
||||||
'password': 'password',
|
'password': 'password',
|
||||||
'username': 'utente_test'
|
'username': 'utente_test'
|
||||||
})
|
})
|
||||||
|
@ -46,13 +47,14 @@ class TestUserDelete:
|
||||||
|
|
||||||
# the admin tries to commit suicide
|
# the admin tries to commit suicide
|
||||||
def test_for_failure(self, flask_client: Client, admin_headers):
|
def test_for_failure(self, flask_client: Client, admin_headers):
|
||||||
|
|
||||||
r = flask_client.delete(f'/api/v1/users/admin@admin.com', headers=admin_headers)
|
r = flask_client.delete(f'/api/v1/users/admin@admin.com', headers=admin_headers)
|
||||||
assert b'failure' in r.data
|
assert b'failure' in r.data
|
||||||
|
|
||||||
|
|
||||||
class TestUserPatch:
|
class TestUserPatch:
|
||||||
|
def test_for_success(self, flask_client: Client, admin_headers, user_create):
|
||||||
|
|
||||||
def test_for_success(self, flask_client: Client, admin_headers):
|
|
||||||
r = flask_client.patch(f'/api/v1/users/admin@admin.com', headers=admin_headers, json={
|
r = flask_client.patch(f'/api/v1/users/admin@admin.com', headers=admin_headers, json={
|
||||||
'username': 'admin_patched'
|
'username': 'admin_patched'
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue