Skip to content

Commit

Permalink
Added test for create_user uniqueness
Browse files Browse the repository at this point in the history
  • Loading branch information
alexpro2022 committed Dec 9, 2023
1 parent 36c0f3c commit d445c5f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tests/unit_tests/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from app.main import lifespan
from tests.conftest import User, override_get_async_session, settings

USER_CREDS = (settings.admin_email, settings.admin_password)

def check_user(user: User, is_superuser: bool = True) -> None:
assert user.email == settings.admin_email
Expand All @@ -14,13 +15,16 @@ def check_user(user: User, is_superuser: bool = True) -> None:
@pytest.mark.asyncio
@pytest.mark.parametrize('is_superuser', (True, False))
async def test_create_user(is_superuser) -> None:
user = await create_user(override_get_async_session,
settings.admin_email,
settings.admin_password,
is_superuser=is_superuser)
user = await create_user(override_get_async_session, *USER_CREDS, is_superuser)
check_user(user, is_superuser)


@pytest.mark.asyncio
async def test_create_user_uniqueness() -> None:
assert await create_user(override_get_async_session, *USER_CREDS)
assert await create_user(override_get_async_session, *USER_CREDS) is None


@pytest.mark.asyncio
async def test_create_admin() -> None:
user = await create_admin(override_get_async_session)
Expand Down

0 comments on commit d445c5f

Please sign in to comment.