2023-11-15 15:37:06 +00:00
|
|
|
import pytest
|
2024-03-15 18:58:06 +00:00
|
|
|
|
2023-12-18 17:06:03 +00:00
|
|
|
from canaille.app.configuration import settings_factory
|
2024-04-16 20:42:29 +00:00
|
|
|
from canaille.backends.sql.backend import SQLBackend
|
2023-11-15 15:37:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def sqlalchemy_configuration(configuration):
|
2023-12-18 17:06:03 +00:00
|
|
|
configuration["CANAILLE_SQL"] = {"DATABASE_URI": "sqlite:///:memory:"}
|
2023-11-15 15:37:06 +00:00
|
|
|
yield configuration
|
2023-12-18 17:06:03 +00:00
|
|
|
del configuration["CANAILLE_SQL"]
|
2023-11-15 15:37:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def sql_backend(sqlalchemy_configuration):
|
2023-12-18 17:06:03 +00:00
|
|
|
config_obj = settings_factory(sqlalchemy_configuration)
|
|
|
|
config_dict = config_obj.model_dump()
|
2024-04-16 20:42:29 +00:00
|
|
|
backend = SQLBackend(config_dict)
|
2025-01-09 17:16:27 +00:00
|
|
|
with backend.session():
|
2023-11-15 15:37:06 +00:00
|
|
|
yield backend
|