From d445c5fb8b8d4e01bd3f7e15dc5707c6927e4ef7 Mon Sep 17 00:00:00 2001 From: Alex Proskuriakov Date: Sat, 9 Dec 2023 22:26:01 +0300 Subject: [PATCH] Added test for create_user uniqueness --- tests/unit_tests/test_user.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/unit_tests/test_user.py b/tests/unit_tests/test_user.py index 9a19a4e..bed4d85 100644 --- a/tests/unit_tests/test_user.py +++ b/tests/unit_tests/test_user.py @@ -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 @@ -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)