chore: finalize delivery cleanup
This commit is contained in:
@@ -31,7 +31,8 @@ TEST_PROMPT = "\n".join([
|
||||
"避免美白/祛斑/速效/医用等违规词;必须保持产品包装与参考图一致。",
|
||||
])
|
||||
|
||||
_REF = ROOT / "test/output/01_连通测试.png"
|
||||
_REF_ENV = os.environ.get("REAL_IMAGE_REF", "").strip()
|
||||
_REF = Path(_REF_ENV).expanduser() if _REF_ENV else None
|
||||
|
||||
|
||||
async def _apiports(key, url, ref, model, size):
|
||||
@@ -73,6 +74,11 @@ async def run():
|
||||
fallback = os.environ.get("IMAGE_PROVIDER_FALLBACK", "codeproxy").lower()
|
||||
out_dir = Path(__file__).parent.parent / "verify_output"
|
||||
out_dir.mkdir(parents=True, exist_ok=True)
|
||||
if _REF is None or not _REF.exists() or not _REF.is_file():
|
||||
raise FileNotFoundError(
|
||||
"请通过 REAL_IMAGE_REF 指定本地参考图路径,例如:"
|
||||
"REAL_IMAGE_REF=/path/to/ref.png python3 scripts/real_image_check.py"
|
||||
)
|
||||
ref = _REF.read_bytes()
|
||||
t0 = time.time(); img = None; used = None
|
||||
for prov in [primary, fallback]:
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
2026-06-09 11:39:33,251 INFO [apiports] 出图中 model=gpt-image-2 size=1024x1536
|
||||
2026-06-09 11:41:04,233 INFO HTTP Request: POST https://www.apiports.com/v1/api/generate "HTTP/1.1 200 OK"
|
||||
2026-06-09 11:41:04,236 ERROR [apiports] 失败: 无法解析: []
|
||||
2026-06-09 11:41:04,236 INFO [codeproxy] 出图中 model=gpt-image-2 size=1024x1536
|
||||
2026-06-09 11:42:33,485 INFO HTTP Request: POST https://codeproxy.dev/v1/images/edits "HTTP/1.1 200 OK"
|
||||
|
||||
===== 出图结果 =====
|
||||
provider: codeproxy
|
||||
耗时: 181.2s
|
||||
大小: 2009KB
|
||||
路径: /Users/qiyu/Documents/企业培训项目/万牛会L1准备/北哥小红书产品/Clover/backend/verify_output/素颜霜_封面hook.png
|
||||
====================
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
"""Task 端到端真跑临时验证脚本。
|
||||
|
||||
手动运行:
|
||||
cd backend && python3 test_3sets_e2e.py
|
||||
"""
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, "/app")
|
||||
|
||||
|
||||
def main():
|
||||
from app.core.database import SessionLocal
|
||||
from app.models.task import GenerationTask
|
||||
from app.constants.enums import TaskStatus
|
||||
from app.workers.tasks import run_generation_pipeline
|
||||
|
||||
db = SessionLocal()
|
||||
try:
|
||||
task = GenerationTask(
|
||||
workspace_id=3,
|
||||
product_id=1,
|
||||
operator_id=3,
|
||||
theme="伪素颜·黄黑皮提亮·3套正交",
|
||||
text_count=1,
|
||||
image_count=2,
|
||||
track="ai",
|
||||
need_product_image=True,
|
||||
status=TaskStatus.PENDING,
|
||||
)
|
||||
db.add(task)
|
||||
db.commit()
|
||||
db.refresh(task)
|
||||
task_id = task.id
|
||||
print(f"建task成功 task_id={task_id} image_count=2 (期望3套×2=6张)")
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
print(f"=== 同步执行 run_generation_pipeline({task_id}) ===")
|
||||
result = run_generation_pipeline.apply(args=[task_id]).get()
|
||||
print(f"=== 结果: {result} ===")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -18,6 +18,9 @@ class _Query:
|
||||
def all(self):
|
||||
return self._rows
|
||||
|
||||
def count(self):
|
||||
return len(self._rows)
|
||||
|
||||
|
||||
class _Db:
|
||||
def __init__(self, text_rows, image_rows):
|
||||
@@ -32,26 +35,44 @@ class _Task:
|
||||
image_count = 3
|
||||
|
||||
|
||||
def test_submit_review_requires_each_strategy_to_select_full_image_count():
|
||||
db = _Db(
|
||||
text_rows=[("A",), ("B",), ("C",)],
|
||||
image_rows=[("A", 1), ("A", 2), ("A", 3), ("B", 4), ("C", 5), ("C", 6), ("C", 7)],
|
||||
)
|
||||
def test_submit_review_requires_at_least_one_text_and_one_image():
|
||||
db = _Db(text_rows=[], image_rows=[])
|
||||
|
||||
with pytest.raises(CloverHTTPException) as exc:
|
||||
task_actions._validate_strategy_selection(db, _Task())
|
||||
|
||||
assert "图片未选满:B(1/3)" in exc.value.biz_message
|
||||
assert "请至少选择 1 条文案" in exc.value.biz_message
|
||||
assert "请至少选择 1 张图片" in exc.value.biz_message
|
||||
|
||||
|
||||
def test_submit_review_passes_when_all_strategies_have_text_and_full_images():
|
||||
def test_submit_review_requires_at_least_one_image():
|
||||
db = _Db(text_rows=[("A",)], image_rows=[])
|
||||
|
||||
with pytest.raises(CloverHTTPException) as exc:
|
||||
task_actions._validate_strategy_selection(db, _Task())
|
||||
|
||||
assert exc.value.biz_message == "请至少选择 1 张图片"
|
||||
|
||||
|
||||
def test_submit_review_requires_at_least_one_text():
|
||||
db = _Db(text_rows=[], image_rows=[("A", 1)])
|
||||
|
||||
with pytest.raises(CloverHTTPException) as exc:
|
||||
task_actions._validate_strategy_selection(db, _Task())
|
||||
|
||||
assert exc.value.biz_message == "请至少选择 1 条文案"
|
||||
|
||||
|
||||
def test_submit_review_passes_with_one_text_and_one_image():
|
||||
db = _Db(text_rows=[("B",)], image_rows=[("C", 7)])
|
||||
|
||||
task_actions._validate_strategy_selection(db, _Task())
|
||||
|
||||
|
||||
def test_submit_review_does_not_require_all_strategies_or_full_image_count():
|
||||
db = _Db(
|
||||
text_rows=[("A",), ("B",), ("C",)],
|
||||
image_rows=[
|
||||
("A", 1), ("A", 2), ("A", 3),
|
||||
("B", 4), ("B", 5), ("B", 6),
|
||||
("C", 7), ("C", 8), ("C", 9),
|
||||
],
|
||||
text_rows=[("A",)],
|
||||
image_rows=[("B", 4)],
|
||||
)
|
||||
|
||||
task_actions._validate_strategy_selection(db, _Task())
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.0 MiB |
Reference in New Issue
Block a user