feat(file-check): 添加文件检核查询结果绑定对话轮次功能,修复空成功批次进度显示问题
This commit is contained in:
1 parent
88fcf3c70b
commit
2878a6998e
6 files changed
+190
-3
No files matched your search
@@ -661,6 +661,66 @@ def test_file_check_tool_lists_runs_without_task_filter(app, client):
|
||||
assert {item['run_no'] for item in data['runs']} == {'RUN-ROHS-001', 'RUN-ROHS-002', 'RUN-OTHER-001'}
|
||||
|
||||
|
||||
def test_latest_file_check_run_binds_existing_run_to_query_turn(app, client):
|
||||
"""查询最近批次只绑定当前对话,不得改写定时任务的原始执行上下文。"""
|
||||
with app.app_context():
|
||||
app.config['INTEGRATION_API_KEY'] = 'secret'
|
||||
admin = _mk_admin()
|
||||
db.session.commit()
|
||||
task = _mk_check_task(admin.id)
|
||||
run = ScheduleRun(
|
||||
run_no='RUN-ROHS-CRON-EMPTY',
|
||||
schedule_task_id=task.id,
|
||||
status='success',
|
||||
trigger_type='cron',
|
||||
total_count=0,
|
||||
api_request_json={'trigger_source': 'cron'},
|
||||
)
|
||||
db.session.add(run)
|
||||
db.session.commit()
|
||||
task_id = task.id
|
||||
run_id = run.id
|
||||
|
||||
from app.models import ChatToolRun
|
||||
from app.services.file_check_tools.chat_tool_run_binding import register_pending_turn
|
||||
from app.services.file_check_tools.chat_turn_registry import register_file_check_chat_turn
|
||||
|
||||
register_file_check_chat_turn(
|
||||
turn_id='turn-query-latest',
|
||||
session_id='session-query-latest',
|
||||
user_id=admin.id,
|
||||
agent_id=1,
|
||||
query='查看最近执行记录',
|
||||
)
|
||||
register_pending_turn(
|
||||
turn_id='turn-query-latest',
|
||||
session_id='session-query-latest',
|
||||
user_id=admin.id,
|
||||
agent_id=1,
|
||||
user_message='查看最近执行记录',
|
||||
schedule_task_id=task_id,
|
||||
)
|
||||
|
||||
res = client.get(
|
||||
f'/api/file-check/tools/tasks/{task_id}/latest-run',
|
||||
query_string={
|
||||
'hxops_turn_id': 'turn-query-latest',
|
||||
'conversation_id': 'session-query-latest',
|
||||
'user_message': '查看最近执行记录',
|
||||
},
|
||||
headers={'X-Integration-Key': 'secret'},
|
||||
)
|
||||
|
||||
assert res.status_code == 200
|
||||
assert res.get_json()['run']['run_id'] == run_id
|
||||
|
||||
with app.app_context():
|
||||
binding = ChatToolRun.query.filter_by(turn_id='turn-query-latest').first()
|
||||
rebound_run = db.session.get(ScheduleRun, run_id)
|
||||
assert binding.schedule_run_id == run_id
|
||||
assert rebound_run.api_request_json == {'trigger_source': 'cron'}
|
||||
|
||||
|
||||
def test_workspace_file_check_active_run_returns_progress(app, client):
|
||||
with app.app_context():
|
||||
admin = _mk_admin()
|
||||
@@ -702,6 +762,35 @@ def test_workspace_file_check_active_run_returns_progress(app, client):
|
||||
assert data['run']['current_step']['row_id'] == 'ROW-16'
|
||||
|
||||
|
||||
def test_workspace_file_check_successful_empty_run_reports_complete_progress(app, client):
|
||||
"""已完成的空批次应展示 100% 进度,避免被误解为尚未执行。"""
|
||||
with app.app_context():
|
||||
admin = _mk_admin()
|
||||
db.session.commit()
|
||||
task = _mk_check_task(admin.id)
|
||||
run = ScheduleRun(
|
||||
run_no='RUN-ROHS-EMPTY',
|
||||
schedule_task_id=task.id,
|
||||
status='success',
|
||||
trigger_type='cron',
|
||||
total_count=0,
|
||||
success_count=0,
|
||||
failed_count=0,
|
||||
skipped_count=0,
|
||||
)
|
||||
db.session.add(run)
|
||||
db.session.commit()
|
||||
run_id = run.id
|
||||
|
||||
res = client.get(
|
||||
f'/api/workspace/file-check/runs/{run_id}',
|
||||
headers={'X-Username': 'admin'},
|
||||
)
|
||||
|
||||
assert res.status_code == 200
|
||||
assert res.get_json()['run']['progress_percent'] == 100
|
||||
|
||||
|
||||
def test_workspace_file_check_active_run_filters_by_task_id(app, client):
|
||||
with app.app_context():
|
||||
admin = _mk_admin()
|
||||
|
||||
Reference in new issue
Block a user