Files

30 lines
1.1 KiB
Python

import pytest_asyncio
from sqlalchemy.ext.asyncio import async_sessionmaker, create_async_engine
from src.models.configs_read.env import env_settings
from src.service.auth.jwt import HashService, JwtService
from src.service.users_crud.users_crud import CrudService
@pytest_asyncio.fixture
async def jwt_service()->JwtService:
jwt_service=JwtService()
return jwt_service
@pytest_asyncio.fixture
async def hash_service()->HashService:
hash_service=HashService()
return hash_service
@pytest_asyncio.fixture
async def crud_service():
test_engine = create_async_engine(f"postgresql+asyncpg://{env_settings.DB_USER}:{env_settings.DB_PASSWORD}@{env_settings.DB_HOST}:{env_settings.DB_PORT}/{env_settings.DB_POSTGRESS}",
pool_size=20,
max_overflow=10,
pool_timeout=30,
pool_pre_ping=True
)
crud_service = CrudService()
crud_service.crud_db_actions.Session = async_sessionmaker(bind=test_engine)
yield crud_service
await test_engine.dispose()