27 lines
561 B
Python
27 lines
561 B
Python
|
import pytest
|
||
|
|
||
|
from sqlalchemy.future.engine import Engine
|
||
|
from sqlmodel import SQLModel, Session
|
||
|
|
||
|
from .config import config_fixture
|
||
|
|
||
|
from diyalgo import models
|
||
|
from diyalgo.db import init_db_engine, create_tables
|
||
|
|
||
|
@pytest.fixture()
|
||
|
def engine_fixture(config_fixture) -> Engine:
|
||
|
"""Create and engine and then create tables"""
|
||
|
engine = init_db_engine(config_fixture)
|
||
|
SQLModel.metadata.create_all(engine)
|
||
|
|
||
|
yield engine
|
||
|
|
||
|
engine.dispose()
|
||
|
|
||
|
@pytest.fixture()
|
||
|
def session_fixture(engine_fixture) -> Session:
|
||
|
return Session(engine_fixture)
|
||
|
|
||
|
|
||
|
|