File size: 1,074 Bytes
ab250f8 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
import pytest
from app.backend.schemas import SUser
def test_password_no_digit():
with pytest.raises(ValueError, match="Password must contain at least one number."):
SUser(email="test@example.ru", password="NoDi@gitPassword!")
def test_password_too_short():
with pytest.raises(ValueError, match="String should have at least 8 characters"):
SUser(email="test@example.ru", password="P1@Sal!")
def test_password_too_long():
with pytest.raises(ValueError, match="String should have at most 32 characters"):
SUser(
email="test@example.ru",
password="Strong.Password123!Strong.Password123!Strong.Password123!Strong.Password123!Strong.Passwor",
)
def test_email():
with pytest.raises(ValueError, match="value is not a valid email address"):
SUser(email="test.test", password="SoMeGrE@tPa22WoRd!")
def test_valid_password():
user = SUser(email="test@example.ru", password="Strong.Password123!")
assert user.email == "test@example.ru"
assert user.password == "Strong.Password123!"
|