Merge branch 'dev' into runny827
feat(training): 新增精益培训视频与周任务管理 # Conflicts: # backend/app/models/__init__.py
This commit is contained in:
1 parent
85d27e9ffa
commit
91b7233872
812 files changed
+73763
-18908
No files matched your search
@@ -53,9 +53,14 @@ def test_inventory_callback_id_is_checked_before_attempt_identity(app):
|
||||
task = ShippingNotice(task_no='SN-CB-ID-FIRST', source_type='manual')
|
||||
db.session.add(task)
|
||||
db.session.flush()
|
||||
# 冻结的逐源 Attempt 须携带完整 v2 身份(lease_token / candidate_set / execution / gate),
|
||||
# 否则回调会先在 _validate_callback_attempt_identity 被 identity_mismatch 拒绝,
|
||||
# 无法走到失败分支去写 callback_id。
|
||||
first = ShippingTaskInventoryRpaAttempt(
|
||||
task_no=task.task_no, source_code='SRC-A', attempt_no=1,
|
||||
source_run_no='PSR-FIRST', status='failed', callback_id=None,
|
||||
lease_token='lease-first',
|
||||
extra_json={'candidate_set_id': 1, 'execution_id': 1, 'gate_id': 1},
|
||||
)
|
||||
second = ShippingTaskInventoryRpaAttempt(
|
||||
task_no='SN-CB-ID-OTHER', source_code='SRC-B', attempt_no=1,
|
||||
@@ -64,23 +69,43 @@ def test_inventory_callback_id_is_checked_before_attempt_identity(app):
|
||||
db.session.add_all([first, second])
|
||||
db.session.flush()
|
||||
|
||||
def _payload(run_no: str, source_code: str, attempt_no: int) -> dict:
|
||||
"""构造完整 v2 身份围栏的回调 payload。
|
||||
|
||||
与 _validate_callback_attempt_identity 的 required 字段一一对应,
|
||||
使失败回调(error_code)能通过身份校验并回写 callback_id。
|
||||
"""
|
||||
return {
|
||||
'schema_version': 'shipping_inventory_rpa.v2',
|
||||
'callback_id': 'cb-unique',
|
||||
'task_no': task.task_no,
|
||||
'source_code': source_code,
|
||||
'source_run_no': run_no,
|
||||
'attempt_no': attempt_no,
|
||||
'lease_token': 'lease-first',
|
||||
'candidate_set_id': 1,
|
||||
'execution_id': 1,
|
||||
'gate_id': 1,
|
||||
'error_code': 'RPA_TIMEOUT',
|
||||
}
|
||||
|
||||
result, handled = per_source_callback_handler(
|
||||
task, source_code='SRC-A', run_no='PSR-FIRST',
|
||||
callback_payload={'callback_id': 'cb-unique', 'error_code': 'RPA_TIMEOUT'},
|
||||
callback_payload=_payload('PSR-FIRST', 'SRC-A', 1),
|
||||
)
|
||||
assert result == 'failed'
|
||||
assert handled.id == first.id
|
||||
|
||||
result, handled = per_source_callback_handler(
|
||||
task, source_code='SRC-A', run_no='PSR-FIRST',
|
||||
callback_payload={'callback_id': 'cb-unique', 'error_code': 'RPA_TIMEOUT'},
|
||||
callback_payload=_payload('PSR-FIRST', 'SRC-A', 1),
|
||||
)
|
||||
assert result == 'idempotent_ok'
|
||||
assert handled.id == first.id
|
||||
|
||||
result, handled = per_source_callback_handler(
|
||||
task, source_code='SRC-B', run_no='PSR-SECOND',
|
||||
callback_payload={'callback_id': 'cb-unique', 'error_code': 'RPA_TIMEOUT'},
|
||||
callback_payload=_payload('PSR-SECOND', 'SRC-B', 1),
|
||||
)
|
||||
assert result == 'callback_conflict'
|
||||
assert handled.id == first.id
|
||||
Reference in new issue
Block a user