Stabilize staff concurrency and premium emoji; enable verified Drone deployment
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
27
tests/conftest.py
Normal file
27
tests/conftest.py
Normal file
@@ -0,0 +1,27 @@
|
||||
"""All tests use disposable databases and a synthetic Telegram token."""
|
||||
import os
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
|
||||
import pytest_asyncio
|
||||
|
||||
_temporary = tempfile.TemporaryDirectory(prefix="lottery-tests-")
|
||||
os.environ["DATABASE_URL"] = os.getenv("TEST_DATABASE_URL") or (
|
||||
"sqlite+aiosqlite:///" + (Path(_temporary.name) / "test.db").as_posix()
|
||||
)
|
||||
os.environ["BOT_TOKEN"] = "123456:TEST_TOKEN_FOR_ISOLATED_TESTS"
|
||||
os.environ["ADMIN_IDS"] = "900001"
|
||||
os.environ["CASHIER_IDS"] = "900002"
|
||||
os.environ["REDIS_URL"] = ""
|
||||
|
||||
from src.core.database import Base, engine, async_session_maker
|
||||
from src.core import models
|
||||
|
||||
|
||||
@pytest_asyncio.fixture(autouse=True)
|
||||
async def database():
|
||||
async with engine.begin() as connection:
|
||||
await connection.run_sync(Base.metadata.drop_all)
|
||||
await connection.run_sync(Base.metadata.create_all)
|
||||
yield async_session_maker
|
||||
await engine.dispose()
|
||||
Reference in New Issue
Block a user