2c59fe5ee2
- App 启动时初始化 RedisService,关闭时释放连接 - Celery worker 通过 worker_process_init 钩子初始化 Redis - Agent 端点改用 RedisService 替代直接创建连接 - Celery task 改为 async def,使用统一连接 - 删除无用的 infra 模块和 core/http/models - 日志脱敏,不记录 Redis 密码 - 初始化失败时 fail-fast - 异常发布添加二级保护
30 lines
751 B
Python
30 lines
751 B
Python
from __future__ import annotations
|
|
|
|
from fastapi.testclient import TestClient
|
|
|
|
from app import app
|
|
|
|
|
|
def test_app_health_returns_envelope() -> None:
|
|
client = TestClient(app)
|
|
|
|
response = client.get("/health")
|
|
|
|
assert response.status_code == 200
|
|
body = response.json()
|
|
assert body["status"] == "ok"
|
|
|
|
|
|
def test_not_found_returns_error_envelope() -> None:
|
|
client = TestClient(app)
|
|
|
|
response = client.get("/missing-route")
|
|
|
|
assert response.status_code == 404
|
|
assert response.headers["content-type"].startswith("application/problem+json")
|
|
body = response.json()
|
|
assert body["type"] == "about:blank"
|
|
assert body["title"] == "Not Found"
|
|
assert body["status"] == 404
|
|
assert body["detail"] == "Not Found"
|