- src/muse 新版全模块(装配/共享/上下文/任务运行/作品规划/故事世界/正文写作/审校修订/知识方法/作者经验/效果评测/交付连载/资料研究/正式变更/元数据/接入/基础设施/编排)+ 测试树(单元/契约/集成/架构/迁移/端到端/夹具) - 129 项功能全部实现与自动验证(功能覆盖.json/矩阵),含 W31 补齐的规则与代价/节奏安排/伏笔与承诺 - 旧实现按处置清单退出(702 条中 324 删,保护合同与未迁移条目留存有据);web/app.py 旧工作台退役,新工作台为唯一写入口 - 数据库/旧库迁移:真实旧库内容批次迁移链(端点守卫/PG作品正文映射/质量资产缺省投影) - 运行手册 docs/运行手册.md;W30 本机服务阶段一已运行(infra PG 为正式内容权威) - R2 执行证据与私有运行材料在 .agents.local/改造/R2-20260909/(不入库)
36 lines
1.3 KiB
Python
36 lines
1.3 KiB
Python
"""旧选题检索的空结果观察由B09真实混合检索承接,不修改B04绑定列表合同。"""
|
||
|
||
from unittest.mock import patch
|
||
|
||
import pytest
|
||
|
||
from muse.上下文.混合检索 import 混合检索
|
||
from muse.共享.错误 import Muse错误
|
||
from muse.基础设施.模型.嵌入 import 特征哈希嵌入器
|
||
|
||
|
||
def test_无命中检索保留明确原因和索引身份__e0a672():
|
||
embedder = 特征哈希嵌入器(512)
|
||
rows = [
|
||
{
|
||
"method_version_id": "version-1",
|
||
"检索文本": "astronomy",
|
||
"vector": embedder.嵌入("astronomy"),
|
||
}
|
||
]
|
||
with patch(
|
||
"muse.上下文.混合检索.读取新鲜索引", return_value=({"索引身份": "index-1"}, rows, {})
|
||
):
|
||
result = 混合检索(object(), "无命中意图", embedder)
|
||
assert result["结果"] == [] and result["索引身份"] == "index-1"
|
||
assert result["empty_reason"] == "no_match"
|
||
assert result["说明"] == "方法检索没有命中可授权卡"
|
||
|
||
|
||
@pytest.mark.parametrize("intent", ["", " \n "])
|
||
def test_空检索意图在读取索引前拒绝__6e73ee(intent):
|
||
with patch("muse.上下文.混合检索.读取新鲜索引") as read:
|
||
with pytest.raises(Muse错误, match="查询"):
|
||
混合检索(object(), intent, 特征哈希嵌入器())
|
||
read.assert_not_called()
|