|
import pytest
|
|
import pytest_asyncio
|
|
import asyncio
|
|
from tortoise import Tortoise
|
|
|
|
|
|
@pytest_asyncio.fixture(scope="session")
|
|
async def init_db():
|
|
"""Initialize the database for testing."""
|
|
await Tortoise.init(
|
|
db_url="sqlite://:memory:",
|
|
modules={"models": ["mywebdav.models"], "billing": ["mywebdav.billing.models"]},
|
|
)
|
|
await Tortoise.generate_schemas()
|
|
yield
|
|
await Tortoise.close_connections()
|
|
|
|
|
|
@pytest_asyncio.fixture(autouse=True)
|
|
async def setup_db(init_db):
|
|
"""Ensure database is initialized before each test."""
|
|
# The init_db fixture handles the setup
|
|
yield
|