fix(rohs-check): 修复检核任务禁用状态处理及错误信息

This commit is contained in:
hugo committed 2026-06-10 20:45:59 +08:00
1 parent 25cc87fdb3
commit 3068e3abb4
15 files changed
+1407 -13

No files matched your search

+20 -3
View File
@@ -208,7 +208,20 @@ def test_rohs_tool_excel_download_uses_signed_token(app, client):
assert res.status_code == 401
def test_rohs_tool_task_disabled(app, client):
def test_rohs_tool_runs_disabled_schedule_immediately(app, client, monkeypatch):
started_threads = []
class _Thread:
def __init__(self, *, target, daemon, name):
self.target = target
self.daemon = daemon
self.name = name
def start(self):
started_threads.append(self.name)
monkeypatch.setattr('app.api.rohs_check_tools.threading.Thread', _Thread)
with app.app_context():
app.config['INTEGRATION_API_KEY'] = 'secret'
admin = _mk_admin()
@@ -221,8 +234,12 @@ def test_rohs_tool_task_disabled(app, client):
headers={'X-Integration-Key': 'secret', 'Content-Type': 'application/json'},
json={'task_id': task_id},
)
assert res.status_code == 400
assert res.get_json()['error_code'] == 'task_disabled'
assert res.status_code == 200
data = res.get_json()
assert data['ok'] is True
assert data['run']['task_id'] == task_id
assert data['run']['status'] == 'running'
assert started_threads == [f"rohs-check-run-{data['run']['run_id']}"]
def test_rohs_openapi_injects_tool_api_base(app, client):