feat(schedule): 新增平台任务参数契约与动态选项支持

This commit is contained in:
hugo committed 2026-07-09 13:19:36 +08:00
1 parent 2ce1aca023
commit 8b5b0b49bf
76 files changed
+7103 -1203

No files matched your search

+32
View File
@@ -154,3 +154,35 @@ def test_post_and_patch_schedule_reject_non_object_config(app, client, admin_jwt
'config': 'not-an-object',
})
assert patch_res.status_code == 400
def test_patch_schedule_creates_config_for_task_without_config(app, client, admin_jwt_headers):
"""PATCH 为尚无 config 的排程写入 config 应成功,不因主键序列漂移 500。"""
with app.app_context():
owner = _mk_user('cfg_create_owner_u', 'cfg_create_owner@example.com')
db.session.commit()
owner_id = owner.id
create_res = client.post('/api/admin/schedules', headers=admin_jwt_headers, json={
'name': 'config-create-schedule',
'schedule_type': 'data_pipeline',
'data_source_type': 'database',
'owner_user_id': owner_id,
'cron_expr': '0 4 * * *',
})
assert create_res.status_code == 201
task_id = create_res.get_json()['id']
patch_res = client.patch(f'/api/admin/schedules/{task_id}', headers=admin_jwt_headers, json={
'config': {
'row_id_key': 'id',
'data_source': {'db_type': 'sqlserver'},
},
})
assert patch_res.status_code == 200
cfg_res = client.get(f'/api/admin/schedule-config/{task_id}', headers=admin_jwt_headers)
assert cfg_res.status_code == 200
cfg_body = cfg_res.get_json()
assert cfg_body['config'] is not None
assert cfg_body['config']['row_id_key'] == 'id'