No longer run migrations in tests

pull/115/head
stijndcl 2022-06-23 11:53:21 +02:00
parent 6b91e792e6
commit 85a7750d09
1 changed files with 7 additions and 11 deletions

View File

@ -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)
""" yield
alembic_config = config.Config("alembic.ini") await connection.run_sync(Base.metadata.drop_all)
command.upgrade(alembic_config, "head")
yield
command.downgrade(alembic_config, "base")
@pytest.fixture @pytest.fixture