初始化提交
This commit is contained in:
commit
887c1f449e
963 files changed
+166869
No files matched your search
@@ -0,0 +1,37 @@
|
||||
"""元炁 Reranker 端点测试。"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from fastapi import status
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from src.main import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
|
||||
def test_rerank_without_model_returns_503() -> None:
|
||||
"""Reranker 端点未加载模型时应返回 503。"""
|
||||
resp = client.post(
|
||||
"/v1/rerank",
|
||||
json={
|
||||
"model": "test-model",
|
||||
"query": "测试查询",
|
||||
"documents": ["文档A", "文档B", "文档C"],
|
||||
},
|
||||
)
|
||||
# 未加载模型时返回 503;安装后若模型就绪则返回 200
|
||||
assert resp.status_code in (
|
||||
status.HTTP_200_OK,
|
||||
status.HTTP_503_SERVICE_UNAVAILABLE,
|
||||
)
|
||||
|
||||
|
||||
def test_rerank_invalid_body() -> None:
|
||||
"""Reranker 端点应对无效请求体返回 422。"""
|
||||
resp = client.post(
|
||||
"/v1/rerank",
|
||||
json={"model": "test", "query": "test"},
|
||||
# 缺少 documents 字段
|
||||
)
|
||||
assert resp.status_code == status.HTTP_422_UNPROCESSABLE_ENTITY
|
||||
Reference in new issue
Block a user