import os import uuid os.environ["ENVIRONMENT"] = "test" os.environ["AUTH_REQUIRED"] = "false" os.environ["WORKSPACE_DATABASE_URL"] = "sqlite+aiosqlite:///:memory:" os.environ["WORKSPACE_DATABASE_URL_SYNC"] = "sqlite:///:memory:" import pytest_asyncio from httpx import ASGITransport, AsyncClient from app.core.database import Base, engine import app.models # noqa: F401 from app.main import app TENANT_A = uuid.uuid4() TENANT_B = uuid.uuid4() def headers(tenant=TENANT_A): return {"X-Tenant-ID": str(tenant)} @pytest_asyncio.fixture async def client(): async with engine.begin() as conn: await conn.run_sync(Base.metadata.drop_all) await conn.run_sync(Base.metadata.create_all) async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as ac: yield ac async def seed_hub(client, tenant=TENANT_A, name="مرکز کار اصلی"): res = await client.post("/api/v1/hubs", headers=headers(tenant), json={"name": name}) assert res.status_code == 201, res.text return res.json()