mirror of
https://github.com/stijndcl/didier.git
synced 2026-04-07 15:48:29 +02:00
Use alembic in tests again?
This commit is contained in:
parent
5c1732d119
commit
b4a3a87e6e
2 changed files with 12 additions and 3 deletions
|
|
@ -5,6 +5,7 @@ from unittest.mock import MagicMock
|
|||
import pytest
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from alembic import config, command
|
||||
from database.engine import engine
|
||||
from database.models import Base
|
||||
from didier import Didier
|
||||
|
|
@ -20,8 +21,10 @@ def event_loop() -> Generator:
|
|||
@pytest.fixture(scope="session")
|
||||
async def tables(event_loop):
|
||||
"""Initialize a database before the tests, and then tear it down again"""
|
||||
async with engine.begin() as connection:
|
||||
await connection.run_sync(Base.metadata.create_all)
|
||||
alembic_config: config.Config = config.Config("alembic.ini")
|
||||
command.upgrade(alembic_config, "head")
|
||||
yield
|
||||
command.downgrade(alembic_config, "base")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue