Add the Healthcare platform backend (phases 13.0–13.7) with Alembic migration revision fix, production deploy script, validation reports, shared UI exports, and loyalty list page client directives so Next.js build succeeds. Co-authored-by: Cursor <cursoragent@cursor.com>
67 lines
1.8 KiB
Python
67 lines
1.8 KiB
Python
import os
|
|
import uuid
|
|
|
|
import pytest
|
|
import pytest_asyncio
|
|
from httpx import ASGITransport, AsyncClient
|
|
|
|
os.environ["ENVIRONMENT"] = "test"
|
|
os.environ["AUTH_REQUIRED"] = "false"
|
|
os.environ["HEALTHCARE_DATABASE_URL"] = "sqlite+aiosqlite:///:memory:"
|
|
os.environ["HEALTHCARE_DATABASE_URL_SYNC"] = "sqlite:///:memory:"
|
|
os.environ["JWT_VERIFY_SIGNATURE"] = "false"
|
|
|
|
from app.core.config import get_settings # noqa: E402
|
|
|
|
get_settings.cache_clear()
|
|
|
|
from app.core.database import Base, engine # noqa: E402
|
|
import app.models # noqa: E402, F401
|
|
from app.events.publisher import reset_event_publisher # noqa: E402
|
|
from app.main import app # noqa: E402
|
|
|
|
TENANT_A = uuid.uuid4()
|
|
TENANT_B = uuid.uuid4()
|
|
|
|
|
|
@pytest_asyncio.fixture
|
|
async def db_setup():
|
|
async with engine.begin() as conn:
|
|
await conn.run_sync(Base.metadata.drop_all)
|
|
await conn.run_sync(Base.metadata.create_all)
|
|
yield
|
|
async with engine.begin() as conn:
|
|
await conn.run_sync(Base.metadata.drop_all)
|
|
|
|
|
|
@pytest.fixture(scope="session", autouse=True)
|
|
def _dispose_engine_on_session_end():
|
|
yield
|
|
import asyncio
|
|
|
|
try:
|
|
asyncio.run(engine.dispose())
|
|
except RuntimeError:
|
|
pass
|
|
|
|
|
|
@pytest_asyncio.fixture(autouse=True)
|
|
def _reset_events():
|
|
from app.providers.mocks import MockCommunicationProvider, MockDeliveryProvider
|
|
|
|
reset_event_publisher()
|
|
MockCommunicationProvider.reset()
|
|
MockDeliveryProvider.reset()
|
|
yield
|
|
|
|
|
|
@pytest_asyncio.fixture
|
|
async def client(db_setup):
|
|
transport = ASGITransport(app=app)
|
|
async with AsyncClient(transport=transport, base_url="http://testserver") as ac:
|
|
yield ac
|
|
|
|
|
|
def tenant_headers(tenant_id: uuid.UUID) -> dict[str, str]:
|
|
return {"X-Tenant-ID": str(tenant_id)}
|