保留5号历史三档实现,新增中下庭高度定位、扶正裁切、矩形叠加与30案例对比页。 worker仅允许本机和配置白名单访问;网关不增加IP限制。空图片URL字段改写限定为52号,保持旧接口兼容。同步接口、裁切与部署文档。 验证:113项测试通过;1项历史数值基线失败,在未修改的a3fddbb版本复现。浏览器验证5/52及30案例对比页通过。
28 lines
1023 B
Python
28 lines
1023 B
Python
"""The legacy interface 5 and new interface 52 forward to separate worker paths."""
|
|
import asyncio
|
|
import importlib
|
|
|
|
import pytest
|
|
from starlette.requests import Request
|
|
|
|
|
|
@pytest.mark.parametrize("name,path", [
|
|
("hairline_generate", "/api/v1/hairline/generate"),
|
|
("hairline_generate_52", "/api/v1/hairline/generate-52"),
|
|
])
|
|
def test_distinct_hairline_forwarding(monkeypatch, name, path):
|
|
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]
|