Files
hair/tests/test_gateway_hairline_routes.py
T
xsl 1c51f3eaab fix: 将52号接口范围限定为GPU worker
撤回52号网关路由、图片字段改名和mock改动,gateway目录恢复a3fddbb。worker保持base64和null响应,更新接口说明和回归测试。

验证:worker API、IP限制与网关兼容性共54项测试通过。
2026-11-04 10:45:16 +08:00

30 lines
1.1 KiB
Python

"""Interface 52 belongs to the GPU worker; the gateway keeps its legacy routes."""
import asyncio
import importlib
from starlette.requests import Request
def test_legacy_hairline_forwarding(monkeypatch):
name, path = "hairline_generate", "/api/v1/hairline/generate"
gateway = importlib.import_module("gateway.app")
request = Request({"type": "http", "method": "POST", "path": path, "headers": []})
calls = []
async def proxy(actual_request, actual_path):
assert actual_request is request
calls.append(actual_path)
return {"forwarded_to": actual_path}
monkeypatch.setattr(gateway, "_proxy", proxy)
endpoint = getattr(gateway, name)
assert next(route for route in gateway.app.routes if getattr(route, "path", None) == path).endpoint is endpoint
assert asyncio.run(endpoint(request)) == {"forwarded_to": path}
assert calls == [path]
def test_interface52_is_not_exposed_by_gateway():
gateway = importlib.import_module("gateway.app")
assert not any(getattr(route, "path", None) == "/api/v1/hairline/generate-52"
for route in gateway.app.routes)