fix(application-form-fill): 优先路由填表提示并支持rar预览
This commit is contained in:
@@ -109,3 +109,38 @@ def test_attachment_reader_skill_returns_structured_details(settings, tmp_path,
|
||||
assert result.success is True
|
||||
assert result.data["attachments"][0]["filename"] == "readme.txt"
|
||||
assert "请读取这个附件" in result.data["attachments"][0]["preview_text"]
|
||||
|
||||
|
||||
def test_read_attachment_extracts_files_inside_rar(monkeypatch, settings, tmp_path, django_user_model):
|
||||
from review_agent.file_summary.services.attachment_reader import read_attachment_details
|
||||
|
||||
settings.MEDIA_ROOT = tmp_path
|
||||
user = django_user_model.objects.create_user(username="owner", password="pass")
|
||||
conversation = Conversation.objects.create(user=user, title="会话")
|
||||
archive_path = tmp_path / "uploads" / "第1章_监管信息.rar"
|
||||
archive_path.parent.mkdir(parents=True)
|
||||
archive_path.write_bytes(b"rar")
|
||||
attachment = FileAttachment.objects.create(
|
||||
conversation=conversation,
|
||||
user=user,
|
||||
original_name="第1章_监管信息.rar",
|
||||
storage_path="uploads/第1章_监管信息.rar",
|
||||
file_size=archive_path.stat().st_size,
|
||||
)
|
||||
|
||||
def fake_extract_archive(path: Path, target_dir: Path):
|
||||
extracted = target_dir / "说明书.txt"
|
||||
extracted.write_text("产品名称:甲胎蛋白检测试剂盒", encoding="utf-8")
|
||||
return [extracted]
|
||||
|
||||
monkeypatch.setattr(
|
||||
"review_agent.file_summary.services.attachment_reader.extract_archive",
|
||||
fake_extract_archive,
|
||||
)
|
||||
|
||||
result = read_attachment_details(attachment)
|
||||
|
||||
assert result.status == "success"
|
||||
assert result.file_type == "rar"
|
||||
assert "说明书.txt" in result.sections[0]["name"]
|
||||
assert "甲胎蛋白检测试剂盒" in result.preview_text
|
||||
|
||||
Reference in New Issue
Block a user