45 lines
1.1 KiB
Python
45 lines
1.1 KiB
Python
import shutil
|
|
|
|
import pytest
|
|
from dbengine.handlers import handlers
|
|
|
|
from myfasthtml.core.data.DataServicesManager import DataServicesManager
|
|
from myfasthtml.core.dbengine_utils import DataFrameHandler
|
|
from myfasthtml.core.dbmanager import DbManager
|
|
from myfasthtml.core.instances import SingleInstance, InstancesManager
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def session():
|
|
handlers.register_handler(DataFrameHandler())
|
|
return {
|
|
"user_info": {
|
|
"id": "test_tenant_id",
|
|
"email": "test@email.com",
|
|
"username": "test user",
|
|
"role": [],
|
|
}
|
|
}
|
|
|
|
|
|
@pytest.fixture
|
|
def parent(session):
|
|
instance = SingleInstance(session=session, _id="test_parent_id")
|
|
return instance
|
|
|
|
|
|
@pytest.fixture
|
|
def db_manager(parent):
|
|
shutil.rmtree("TestDb", ignore_errors=True)
|
|
db_manager_instance = DbManager(parent, root="TestDb", auto_register=True)
|
|
|
|
yield db_manager_instance
|
|
|
|
shutil.rmtree("TestDb", ignore_errors=True)
|
|
InstancesManager.reset()
|
|
|
|
|
|
@pytest.fixture
|
|
def dsm(parent, db_manager):
|
|
return DataServicesManager(parent, parent._session)
|