|
|
@ -3,11 +3,11 @@ from fastapi.encoders import jsonable_encoder |
|
|
|
from app import crud |
|
|
|
from app.db.session import db_session |
|
|
|
from app.schemas.user import UserCreate |
|
|
|
from app.tests.utils.utils import random_lower_string |
|
|
|
from app.tests.utils.utils import random_lower_string, random_email |
|
|
|
|
|
|
|
|
|
|
|
def test_create_user(): |
|
|
|
email = random_lower_string() |
|
|
|
email = random_email() |
|
|
|
password = random_lower_string() |
|
|
|
user_in = UserCreate(email=email, password=password) |
|
|
|
user = crud.user.create(db_session, obj_in=user_in) |
|
|
@ -16,7 +16,7 @@ def test_create_user(): |
|
|
|
|
|
|
|
|
|
|
|
def test_authenticate_user(): |
|
|
|
email = random_lower_string() |
|
|
|
email = random_email() |
|
|
|
password = random_lower_string() |
|
|
|
user_in = UserCreate(email=email, password=password) |
|
|
|
user = crud.user.create(db_session, obj_in=user_in) |
|
|
@ -28,14 +28,14 @@ def test_authenticate_user(): |
|
|
|
|
|
|
|
|
|
|
|
def test_not_authenticate_user(): |
|
|
|
email = random_lower_string() |
|
|
|
email = random_email() |
|
|
|
password = random_lower_string() |
|
|
|
user = crud.user.authenticate(db_session, email=email, password=password) |
|
|
|
assert user is None |
|
|
|
|
|
|
|
|
|
|
|
def test_check_if_user_is_active(): |
|
|
|
email = random_lower_string() |
|
|
|
email = random_email() |
|
|
|
password = random_lower_string() |
|
|
|
user_in = UserCreate(email=email, password=password) |
|
|
|
user = crud.user.create(db_session, obj_in=user_in) |
|
|
@ -44,7 +44,7 @@ def test_check_if_user_is_active(): |
|
|
|
|
|
|
|
|
|
|
|
def test_check_if_user_is_active_inactive(): |
|
|
|
email = random_lower_string() |
|
|
|
email = random_email() |
|
|
|
password = random_lower_string() |
|
|
|
user_in = UserCreate(email=email, password=password, disabled=True) |
|
|
|
user = crud.user.create(db_session, obj_in=user_in) |
|
|
@ -53,7 +53,7 @@ def test_check_if_user_is_active_inactive(): |
|
|
|
|
|
|
|
|
|
|
|
def test_check_if_user_is_superuser(): |
|
|
|
email = random_lower_string() |
|
|
|
email = random_email() |
|
|
|
password = random_lower_string() |
|
|
|
user_in = UserCreate(email=email, password=password, is_superuser=True) |
|
|
|
user = crud.user.create(db_session, obj_in=user_in) |
|
|
@ -62,7 +62,7 @@ def test_check_if_user_is_superuser(): |
|
|
|
|
|
|
|
|
|
|
|
def test_check_if_user_is_superuser_normal_user(): |
|
|
|
username = random_lower_string() |
|
|
|
username = random_email() |
|
|
|
password = random_lower_string() |
|
|
|
user_in = UserCreate(email=username, password=password) |
|
|
|
user = crud.user.create(db_session, obj_in=user_in) |
|
|
@ -72,7 +72,7 @@ def test_check_if_user_is_superuser_normal_user(): |
|
|
|
|
|
|
|
def test_get_user(): |
|
|
|
password = random_lower_string() |
|
|
|
username = random_lower_string() |
|
|
|
username = random_email() |
|
|
|
user_in = UserCreate(email=username, password=password, is_superuser=True) |
|
|
|
user = crud.user.create(db_session, obj_in=user_in) |
|
|
|
user_2 = crud.user.get(db_session, id=user.id) |
|
|
|