1) 客服 Agent 四份交付文档 + 构建脚手架:品牌由包装占位 XX科技 / 旧名 南方财富 统一为南方基金(热线 400-889-8899 / 官网 nffund.com),系统名改为「智能服务系统」; 同步追加 §0.4 修订记录行,工程记录行保留原占位字面以支撑硬编码扫描验收。 2) 开发文档:清理 28 份已作废/残留文档(14 份移出归档 + 14 份仓库副本), 新增《文档规整方案与开发前待决事项-2026-09-17》。 3) 客服agent 四份交付文档首次纳入本分支。
62 lines
1.8 KiB
Python
62 lines
1.8 KiB
Python
import pytest
|
|
|
|
from app.core.knowledge_contracts import KnowledgeHit, KnowledgeQuery
|
|
from app.service.knowledge_authority import KnowledgeMysqlAuthority
|
|
|
|
|
|
class FakeRow:
|
|
id = 101
|
|
title = "申购规则"
|
|
content_text = '{"answer":"工作日确认"}'
|
|
version = "v2"
|
|
milvus_collection = "fin_policy_collection"
|
|
|
|
|
|
class FakeSession:
|
|
statement = None
|
|
|
|
async def scalars(self, statement):
|
|
self.statement = statement
|
|
return [FakeRow()]
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_authority_filters_to_published_active_effective_knowledge() -> None:
|
|
session = FakeSession()
|
|
authority = KnowledgeMysqlAuthority(session)
|
|
|
|
hits = await authority.filter_published((
|
|
KnowledgeHit(
|
|
knowledge_id="101", collection="fin_policy_collection", snippet="摘要", score=0.91,
|
|
),
|
|
))
|
|
|
|
statement = str(session.statement)
|
|
assert "review_status" in statement
|
|
assert "status" in statement
|
|
assert "effective_date" in statement
|
|
assert "expire_date" in statement
|
|
assert hits[0].answer == "工作日确认"
|
|
assert hits[0].version == "v2"
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_authority_keyword_fallback_only_returns_effective_public_knowledge() -> None:
|
|
session = FakeSession()
|
|
authority = KnowledgeMysqlAuthority(session)
|
|
|
|
hits = await authority.search_keyword(
|
|
KnowledgeQuery(query="基金 申购确认", intents=("policy_explain",)),
|
|
("fin_policy_collection",),
|
|
5,
|
|
)
|
|
|
|
statement = str(session.statement)
|
|
assert "milvus_collection" in statement
|
|
assert "content_text" in statement
|
|
assert "review_status" in statement
|
|
assert "effective_date" in statement
|
|
assert hits[0].knowledge_id == "101"
|
|
assert hits[0].collection == "fin_policy_collection"
|
|
assert hits[0].answer == "工作日确认"
|