feat: 支持会话内补传资料并保持绑定
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from django.urls import reverse
|
||||
from django.core.files.uploadedfile import SimpleUploadedFile
|
||||
|
||||
from agent_core.results import AgentResult
|
||||
from apps.audit.models import AgentAuditLog
|
||||
@@ -325,3 +326,40 @@ def test_chat_page_shows_upload_entry_and_dynamic_context_cards(client, db):
|
||||
assert "是否允许正式导出" in content
|
||||
assert "通知状态" in content
|
||||
assert "飞书通知 / 待处理" in content
|
||||
|
||||
|
||||
def test_chat_upload_keeps_existing_conversation_binding_and_adds_documents(client, db):
|
||||
batch, conversation = _create_conversation_with_batch()
|
||||
existing_document = UploadedDocument.objects.create(
|
||||
batch=batch,
|
||||
scenario_id="document_review",
|
||||
original_name="原说明书.md",
|
||||
file_type="md",
|
||||
size=1,
|
||||
status=UploadedDocument.STATUS_INDEXED,
|
||||
)
|
||||
existing_count = UploadedDocument.objects.filter(batch=batch).count()
|
||||
upload_file = SimpleUploadedFile(
|
||||
"新增补充资料.txt",
|
||||
"产品名称:新型冠状病毒 2019-nCoV 核酸检测试剂盒".encode("utf-8"),
|
||||
content_type="text/plain",
|
||||
)
|
||||
|
||||
response = client.post(
|
||||
reverse("chat:upload-documents", args=[conversation.conversation_id]),
|
||||
{"files": [upload_file]},
|
||||
follow=True,
|
||||
)
|
||||
|
||||
content = response.content.decode("utf-8")
|
||||
batch.refresh_from_db()
|
||||
conversation.refresh_from_db()
|
||||
assert response.status_code == 200
|
||||
assert SubmissionBatch.objects.count() == 1
|
||||
assert Conversation.objects.count() == 1
|
||||
assert conversation.conversation_id == "conv-001"
|
||||
assert batch.conversation_id == conversation.conversation_id
|
||||
assert UploadedDocument.objects.filter(batch=batch).count() == existing_count + 1
|
||||
assert UploadedDocument.objects.filter(batch=batch, original_name="新增补充资料.txt").exists()
|
||||
assert "新增补充资料.txt" in content
|
||||
assert "已补充到当前资料包" in content
|
||||
|
||||
Reference in New Issue
Block a user