fix: 将52号接口范围限定为GPU worker
撤回52号网关路由、图片字段改名和mock改动,gateway目录恢复a3fddbb。worker保持base64和null响应,更新接口说明和回归测试。 验证:worker API、IP限制与网关兼容性共54项测试通过。
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
"""Nullable/deprecated worker images retain their documented gateway keys."""
|
||||
"""Keep the gateway's historical image-field conversion unchanged."""
|
||||
import asyncio
|
||||
import json
|
||||
from types import SimpleNamespace
|
||||
@@ -11,14 +11,12 @@ from starlette.requests import Request
|
||||
from gateway.forward import rewrite_base64_to_url
|
||||
|
||||
|
||||
def test_nullable_image_fields_keep_external_names(tmp_path):
|
||||
def test_nullable_image_fields_keep_original_names(tmp_path):
|
||||
value = {"hairline_images": [{"image_high_base64": None, "image_low_base64": None,
|
||||
"grown_image_base64": None}],
|
||||
"high_hairline_center_point": None, "face_measure": None}
|
||||
actual = rewrite_base64_to_url(value, "https://example.test", str(tmp_path), rewrite_null_images=True)
|
||||
assert actual == {"hairline_images": [{"image_high_url": None, "image_low_url": None,
|
||||
"grown_image_url": None}],
|
||||
"high_hairline_center_point": None, "face_measure": None}
|
||||
actual = rewrite_base64_to_url(value, "https://example.test", str(tmp_path))
|
||||
assert actual == value
|
||||
assert not list(tmp_path.iterdir())
|
||||
|
||||
|
||||
@@ -30,23 +28,18 @@ def test_nonempty_images_still_rewrite_alongside_null_fields(tmp_path):
|
||||
Image.new("RGBA", (2, 2), (255, 255, 255, 0)).save(buf, format="PNG")
|
||||
value = {"image_middle_base64": base64.b64encode(buf.getvalue()).decode(),
|
||||
"image_high_base64": None}
|
||||
actual = rewrite_base64_to_url(value, "https://example.test", str(tmp_path), rewrite_null_images=True)
|
||||
actual = rewrite_base64_to_url(value, "https://example.test", str(tmp_path))
|
||||
assert actual["image_middle_url"].startswith("https://example.test/static/annotations/")
|
||||
assert actual["image_high_url"] is None
|
||||
assert actual["image_high_base64"] is None
|
||||
assert "image_high_url" not in actual
|
||||
assert len(list(tmp_path.iterdir())) == 1
|
||||
|
||||
|
||||
def test_legacy_nullable_image_field_names_remain_unchanged(tmp_path):
|
||||
value = {"hairline_images": [{"grown_image_base64": None}], "face_measure": None}
|
||||
assert rewrite_base64_to_url(value, "https://example.test", str(tmp_path)) == value
|
||||
assert not list(tmp_path.iterdir())
|
||||
|
||||
|
||||
@pytest.mark.parametrize("path,expected_key", [
|
||||
("/api/v1/hairline/generate", "grown_image_base64"),
|
||||
("/api/v1/hairline/generate-52", "grown_image_url"),
|
||||
("/api/v1/hair/grow", "grown_image_base64"),
|
||||
])
|
||||
def test_proxy_rewrites_null_images_only_for_interface52(tmp_path, monkeypatch, path, expected_key):
|
||||
def test_proxy_keeps_original_null_image_fields(tmp_path, monkeypatch, path, expected_key):
|
||||
import gateway.config as config
|
||||
import gateway.forward as forward
|
||||
|
||||
|
||||
Reference in New Issue
Block a user