feat: 收口知识库治理配置与模板映射
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
from django.urls import reverse
|
||||
from django.test import override_settings
|
||||
|
||||
from apps.platform_ui.services import get_platform_demo_context
|
||||
|
||||
|
||||
def test_knowledge_base_page_shows_governance_sections(client):
|
||||
@@ -30,3 +33,70 @@ def test_knowledge_base_page_shows_owner_mapping_fields_and_notify_reasons(clien
|
||||
assert "notify_enabled" in content
|
||||
assert "task_completed" in content
|
||||
assert "task_failed" in content
|
||||
|
||||
|
||||
@override_settings(GOVERNANCE_CONFIG_PATH="")
|
||||
def test_get_platform_demo_context_reads_governance_yaml(tmp_path):
|
||||
config_path = tmp_path / "governance.yaml"
|
||||
config_path.write_text(
|
||||
"""
|
||||
owner_mappings:
|
||||
- owner_role: 临床注册负责人
|
||||
owner_name: 王五
|
||||
department: 临床事务部
|
||||
chapter_scope: CH3-CH6
|
||||
risk_scope: 高风险阻断
|
||||
feishu_user_id: ou_test_owner
|
||||
feishu_open_id: on_test_owner
|
||||
feishu_name: 王五
|
||||
notify_enabled: 是
|
||||
feishu_configs:
|
||||
- config_name: Demo 完成通知
|
||||
notify_reason: task_completed
|
||||
channel: 群机器人
|
||||
message_template: 审核完成摘要 + @处理人
|
||||
status: 启用
|
||||
template_mappings:
|
||||
- template_name: 注册证导出模板
|
||||
output_type: registration_word_export_report
|
||||
version: V1.0
|
||||
placeholder_count: 12
|
||||
status: 启用
|
||||
field_mapping_summary: 产品名称 / 注册人 / 适用机型
|
||||
""".strip(),
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
with override_settings(GOVERNANCE_CONFIG_PATH=config_path):
|
||||
context = get_platform_demo_context()
|
||||
|
||||
assert context["owner_mappings"][0]["owner_name"] == "王五"
|
||||
assert context["feishu_configs"][0]["notify_reason"] == "task_completed"
|
||||
assert context["template_mappings"][0]["template_name"] == "注册证导出模板"
|
||||
assert context["template_mappings"][0]["field_mapping_summary"] == "产品名称 / 注册人 / 适用机型"
|
||||
|
||||
|
||||
@override_settings(GOVERNANCE_CONFIG_PATH="")
|
||||
def test_knowledge_base_page_shows_template_mappings_from_governance_config(client, tmp_path):
|
||||
config_path = tmp_path / "governance.yaml"
|
||||
config_path.write_text(
|
||||
"""
|
||||
template_mappings:
|
||||
- template_name: 风险摘要导出模板
|
||||
output_type: registration_word_export_report
|
||||
version: V2.0
|
||||
placeholder_count: 8
|
||||
status: 灰度中
|
||||
field_mapping_summary: 风险等级 / 产品名称 / 责任人
|
||||
""".strip(),
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
with override_settings(GOVERNANCE_CONFIG_PATH=config_path):
|
||||
response = client.get(reverse("platform_ui:knowledge-base"))
|
||||
|
||||
content = response.content.decode("utf-8")
|
||||
assert response.status_code == 200
|
||||
assert "Word 模板与字段映射" in content
|
||||
assert "风险摘要导出模板" in content
|
||||
assert "风险等级 / 产品名称 / 责任人" in content
|
||||
|
||||
Reference in New Issue
Block a user