feat(shipping-notice): 新增临时库存管理功能,支持创建会话、获取分析结果及字段映射建议
This commit is contained in:
1 parent
46eb63f5bb
commit
e9bdd81f1a
320 files changed
+28361
-10487
No files matched your search
@@ -203,6 +203,50 @@ def test_chat_turn_multipart_upload_reads_agent_id_from_form(app, client, monkey
|
||||
assert "run.failed" not in event_names
|
||||
|
||||
|
||||
def test_chat_turn_task_inventory_upload_uses_formal_inventory_handler(app, client, monkeypatch):
|
||||
"""任务级库存附件必须进入 formal upload handler,而不是临时对话库存会话。"""
|
||||
from io import BytesIO
|
||||
|
||||
user = _create_user()
|
||||
agent = _create_shipping_agent()
|
||||
task_no = _create_task_for_user(user.id)
|
||||
captured: dict[str, object] = {}
|
||||
|
||||
def fake_upload_inventory(received_task_no, upload):
|
||||
captured['task_no'] = received_task_no
|
||||
captured['filename'] = upload.filename
|
||||
captured['content'] = upload.read()
|
||||
return {
|
||||
'status': 'ok', 'message': '库存文件已按发布方案解析。',
|
||||
'data': {'schema_preview': {'headers': ['Supplier Sku']}, 'inventory_file_no': 'SIF-TURN-001'},
|
||||
}
|
||||
|
||||
monkeypatch.setattr(
|
||||
'app.services.shipping_notice.chat_action_extended_handlers.shipping_tools.upload_inventory_file',
|
||||
fake_upload_inventory,
|
||||
)
|
||||
res = client.post(
|
||||
'/api/chat/turns/stream',
|
||||
headers={'X-Username': user.username, 'X-Role': user.role},
|
||||
data={
|
||||
'agent_id': str(agent.id),
|
||||
'input': json.dumps({
|
||||
'type': 'upload_followup', 'display_text': '上传库存文件:task.xls',
|
||||
'action_type': 'shipping.upload_inventory', 'payload': {'task_no': task_no},
|
||||
}, ensure_ascii=False),
|
||||
'files': (BytesIO(b'legacy-inventory'), 'task.xls'),
|
||||
},
|
||||
content_type='multipart/form-data',
|
||||
)
|
||||
|
||||
assert res.status_code == 200
|
||||
events = _parse_sse_events(res.get_data(as_text=True))
|
||||
assert 'run.failed' not in [item.get('event') for item in events]
|
||||
assert captured == {'task_no': task_no, 'filename': 'task.xls', 'content': b'legacy-inventory'}
|
||||
assistant_payloads = [item.get('data', {}).get('payload', {}) for item in events if item.get('event') == 'message.completed']
|
||||
assert all('schema_preview' not in payload for payload in assistant_payloads)
|
||||
|
||||
|
||||
def test_chat_turn_create_batch_forwards_idempotency_key(app, client, monkeypatch, tmp_path):
|
||||
"""shipping.create_batch_from_notices 应透传 payload 中的建单幂等键。"""
|
||||
from io import BytesIO
|
||||
|
||||
Reference in new issue
Block a user