31 lines
789 B
Python
31 lines
789 B
Python
import pytest
|
|
from httpx import AsyncClient
|
|
|
|
from app.config import settings
|
|
from app.database import Base, engine
|
|
from app.models import URLs # noqa
|
|
from app.main import app as fastapi_app
|
|
from app.r import get_redis_client
|
|
|
|
|
|
@pytest.fixture(autouse=True, scope="module")
|
|
async def prepare_database():
|
|
assert settings.MODE == "TEST"
|
|
|
|
async with engine.begin() as conn:
|
|
await conn.run_sync(Base.metadata.drop_all)
|
|
await conn.run_sync(Base.metadata.create_all)
|
|
|
|
|
|
@pytest.fixture(autouse=True, scope="module")
|
|
async def prepare_redis():
|
|
assert settings.MODE == "TEST"
|
|
|
|
r = get_redis_client()
|
|
await r.flushdb()
|
|
|
|
|
|
@pytest.fixture(scope="function")
|
|
async def ac():
|
|
async with AsyncClient(app=fastapi_app, base_url="http://test") as ac:
|
|
yield ac
|