2022-12-26 17:07:23 +00:00
|
|
|
import sqlite3
|
|
|
|
|
2022-12-20 09:25:12 +00:00
|
|
|
import pytest
|
|
|
|
from sqlalchemy import create_engine
|
|
|
|
from sqlalchemy.orm import clear_mappers, sessionmaker
|
|
|
|
|
|
|
|
from backend.adapters.orm import metadata, start_mappers
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def in_memory_db():
|
|
|
|
engine = create_engine("sqlite:///:memory:")
|
|
|
|
metadata.create_all(engine)
|
|
|
|
return engine
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def session(in_memory_db):
|
|
|
|
start_mappers()
|
|
|
|
yield sessionmaker(bind=in_memory_db)()
|
|
|
|
clear_mappers()
|
2022-12-26 17:07:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def sqlite_conn():
|
|
|
|
conn = sqlite3.connect(":memory:")
|
|
|
|
yield conn
|
|
|
|
conn.close()
|