Implement ops-hub bootstrap compatibility

This commit is contained in:
2026-06-27 13:04:54 +02:00
parent 1e87adbcbb
commit c532ad8731
21 changed files with 1330 additions and 402 deletions

View File

@@ -1,14 +1,33 @@
import pytest
from fastapi.testclient import TestClient
from sqlalchemy.ext.asyncio import AsyncEngine, create_async_engine
import core_hub.models # noqa: F401
from core_hub.app import create_app
from core_hub.db import Base
from core_hub.config import get_settings
from core_hub.db import Base, get_engine, get_sessionmaker
@pytest.fixture
def app():
return create_app()
def app(monkeypatch, tmp_path):
monkeypatch.setenv("CORE_HUB_DATABASE_URL", f"sqlite+aiosqlite:///{tmp_path / 'core-hub.db'}")
monkeypatch.setenv("CORE_HUB_API_TOKEN", "operator-token")
monkeypatch.setenv("CORE_HUB_AUTO_CREATE_TABLES", "1")
get_settings.cache_clear()
get_engine.cache_clear()
get_sessionmaker.cache_clear()
try:
yield create_app()
finally:
get_settings.cache_clear()
get_engine.cache_clear()
get_sessionmaker.cache_clear()
@pytest.fixture
def client(app):
with TestClient(app) as test_client:
yield test_client
@pytest.fixture