签入版本

This commit is contained in:
2026-09-12 18:24:41 +08:00
commit fb2b7d9538
852 changed files with 115466 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
"""集成测试 fixture:真实 FastAPI 应用 + ASGI client(需 MySQL/Redis 运行)。"""
import httpx
import pytest
import pytest_asyncio
from core import jwt as core_jwt
from core.app import create_app
@pytest.fixture
def app():
return create_app()
@pytest_asyncio.fixture
async def client(app):
# 手动运行 Redis lifespan(当前 httpx 版本不支持 ASGITransport lifespan 参数)
from core.redis_client import redis_lifespan
transport = httpx.ASGITransport(app=app)
async with redis_lifespan(app):
async with httpx.AsyncClient(transport=transport, base_url="http://test") as c:
yield c
@pytest.fixture
def admin_headers():
"""userId=1 管理员 token(绕过 permission_required 权限校验)。"""
token = core_jwt.create_token(
{"userId": 1, "username": "admin", "realname": "admin"})
return {"Authorization": f"Bearer {token}"}