mirror of https://github.com/stijndcl/didier
No longer run migrations in tests
parent
6b91e792e6
commit
85a7750d09
|
@ -3,11 +3,10 @@ from typing import AsyncGenerator, Generator
|
||||||
from unittest.mock import MagicMock
|
from unittest.mock import MagicMock
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from alembic import command, config
|
|
||||||
from sqlalchemy.ext.asyncio import AsyncSession
|
from sqlalchemy.ext.asyncio import AsyncSession
|
||||||
|
|
||||||
from database.engine import engine
|
from database.engine import engine
|
||||||
|
from database.models import Base
|
||||||
from didier import Didier
|
from didier import Didier
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,15 +18,12 @@ def event_loop() -> Generator:
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="session")
|
@pytest.fixture(scope="session")
|
||||||
def tables(event_loop):
|
async def tables(event_loop):
|
||||||
"""Initialize a database before the tests, and then tear it down again
|
"""Initialize a database before the tests, and then tear it down again"""
|
||||||
Starts from an empty database and runs through all the migrations to check those as well
|
async with engine.begin() as connection:
|
||||||
while we're at it
|
await connection.run_sync(Base.metadata.create_all)
|
||||||
"""
|
|
||||||
alembic_config = config.Config("alembic.ini")
|
|
||||||
command.upgrade(alembic_config, "head")
|
|
||||||
yield
|
yield
|
||||||
command.downgrade(alembic_config, "base")
|
await connection.run_sync(Base.metadata.drop_all)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
|
|
Loading…
Reference in New Issue