8cea7dee20
- SiteForge Enterprise V8.10.0-dev.1 upstream source (210 tests) - Fix: v8_workflows._mapped_input now reads both 类型/分类 columns so WXR imports keep post/product types instead of collapsing to page - Docs: trade-pro theme port spec (R3) and implementation plan Co-Authored-By: Claude Code <noreply@anthropic.com>
25 lines
1.1 KiB
Python
25 lines
1.1 KiB
Python
"""Legacy tests assert a synchronous response. Adapt ONLY tests via the actual worker.
|
|
|
|
Production /builds always returns HTTP 202. This testing adapter submits to the
|
|
real queue, drains it through the worker executor and returns the legacy report.
|
|
It must never be imported from app/ or the production frontend.
|
|
"""
|
|
import json
|
|
import re
|
|
from fastapi.testclient import TestClient
|
|
from httpx import Response
|
|
from app import builder,db,worker
|
|
|
|
class LegacyTestClient(TestClient):
|
|
def post(self,url,*args,**kwargs):
|
|
r=super().post(url,*args,**kwargs)
|
|
if r.status_code==202 and re.fullmatch(r'/api/sites/[^/]+/builds',str(url)):
|
|
result=r.json()
|
|
job=result['id']
|
|
worker.run_once(executor=lambda sid,opts: builder.build(sid,bool(opts.get('mirror_images',False))))
|
|
record=db.one('SELECT * FROM build_jobs WHERE id=?',(job,))
|
|
if record['state']=='done':
|
|
return Response(200,json=json.loads(record['result_json']),request=r.request)
|
|
return Response(400,json={'detail':record['error']},request=r.request)
|
|
return r
|