From a8c4b622a4fc1bbcacdcf3c82e530180f8050f73 Mon Sep 17 00:00:00 2001 From: IluaAir Date: Tue, 19 Aug 2025 17:06:53 +0300 Subject: [PATCH] test auth api, add auth fixture --- tests/conftest.py | 10 ++++++++++ tests/integration_tests/test_auth_api.py | 1 - 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index 0df8e78..521a923 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -7,6 +7,7 @@ from src.api.dependacies.db_dep import get_db from src.core.auth_manager import AuthManager from src.core.database import Base from src.core.db_manager import DBManager +from src.core.settings import settings from src.main import app from src.models import * # noqa: F403 @@ -65,3 +66,12 @@ async def add_admin(setup_database): await conn.commit() admin = result.scalar_one() assert admin.is_superuser is True + + +@pytest.fixture +def auth_token(ac, add_admin): + response = ac.post( + f"{settings.api.v1_login_url}/login", + data={"username": "admin", "password": "admin"}, + ) + return response.json()["access_token"] diff --git a/tests/integration_tests/test_auth_api.py b/tests/integration_tests/test_auth_api.py index c74cbd0..a42545a 100644 --- a/tests/integration_tests/test_auth_api.py +++ b/tests/integration_tests/test_auth_api.py @@ -26,4 +26,3 @@ async def test_login(ac: AsyncClient): ) assert result.status_code == 200 assert result.json().get("access_token") -