feat(shipping-notice): 新增货代客户管理功能,支持客户导入、识别证据管理与客户确认
This commit is contained in:
1 parent
b595e157e9
commit
4fbaed2b4c
176 files changed
+14011
-994
No files matched your search
@@ -1,7 +1,9 @@
|
||||
"""
|
||||
tests/test_chat_executors_registry.py
|
||||
|
||||
用途:RUNTIME_PROVIDER_REGISTRY 与 Hybrid Executor 单元测试。
|
||||
用途:RUNTIME_PROVIDER_REGISTRY、Hybrid Executor 与 Handler 前置时序单元测试。
|
||||
依赖:executor registry、agent handler/context adapter bootstrap、pytest Flask fixture。
|
||||
逻辑:验证 provider 解析、Handler 强制约束,以及 prepare_stream 在上游生成器迭代前完成。
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -93,3 +95,36 @@ def test_stream_chat_via_executor_delegates_to_dify(app, monkeypatch):
|
||||
assert captured['kwargs']['session_id'] == 'sess-1'
|
||||
inputs = captured['kwargs'].get('inputs') or {}
|
||||
assert 'agent_runtime_context' in inputs
|
||||
|
||||
|
||||
def test_stream_chat_via_executor_prepares_handler_before_generator_iteration(app, monkeypatch):
|
||||
"""Handler 必须在返回惰性上游生成器前完成准备,供 chat.py preface 立即读取领域状态。"""
|
||||
prepared = {'count': 0}
|
||||
|
||||
class _Handler:
|
||||
def prepare_stream(self, ctx):
|
||||
prepared['count'] += 1
|
||||
ctx.hxops_turn_id = 'prepared-before-preface'
|
||||
return ctx
|
||||
|
||||
with app.app_context():
|
||||
monkeypatch.setattr(
|
||||
'app.services.chat.executors.resolve_handler_for_agent_code',
|
||||
lambda agent: _Handler(),
|
||||
)
|
||||
ctx = ChatStreamContext(
|
||||
query='hello',
|
||||
display_query='hello',
|
||||
user=SimpleNamespace(id=1),
|
||||
agent=_agent(),
|
||||
session=SimpleNamespace(session_id='sess-prepare'),
|
||||
external_conversation_id=None,
|
||||
request_id='req-prepare',
|
||||
)
|
||||
|
||||
generator = stream_chat_via_executor(ctx)
|
||||
|
||||
# 关键断言:此时尚未 list(generator),prepare 已同步完成且只执行一次。
|
||||
assert prepared['count'] == 1
|
||||
assert ctx.hxops_turn_id == 'prepared-before-preface'
|
||||
assert generator is not None
|
||||
Reference in new issue
Block a user