feat: 支持治理配置通过admin维护
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
from django.urls import reverse
|
||||
from django.test import override_settings
|
||||
from django.contrib import admin
|
||||
|
||||
from apps.platform_ui.services import get_platform_demo_context
|
||||
from apps.platform_ui.models import FeishuNotifyConfig, OwnerMapping, WordTemplateMapping
|
||||
|
||||
|
||||
def test_knowledge_base_page_shows_governance_sections(client):
|
||||
@@ -100,3 +102,47 @@ template_mappings:
|
||||
assert "Word 模板与字段映射" in content
|
||||
assert "风险摘要导出模板" in content
|
||||
assert "风险等级 / 产品名称 / 责任人" in content
|
||||
|
||||
|
||||
def test_get_platform_demo_context_prefers_database_governance_entries(db):
|
||||
OwnerMapping.objects.create(
|
||||
owner_role="数据库负责人",
|
||||
owner_name="周八",
|
||||
department="注册事务部",
|
||||
chapter_scope="CH5",
|
||||
risk_scope="数据库覆盖",
|
||||
feishu_user_id="ou_db_1",
|
||||
feishu_open_id="on_db_1",
|
||||
feishu_name="周八",
|
||||
notify_enabled=True,
|
||||
is_active=True,
|
||||
)
|
||||
FeishuNotifyConfig.objects.create(
|
||||
config_name="数据库通知配置",
|
||||
notify_reason="task_failed",
|
||||
channel="群机器人",
|
||||
message_template="异常摘要 + @处理人",
|
||||
status="启用",
|
||||
is_active=True,
|
||||
)
|
||||
WordTemplateMapping.objects.create(
|
||||
template_name="数据库模板",
|
||||
output_type="registration_word_export_report",
|
||||
version="V3.0",
|
||||
placeholder_count=16,
|
||||
status="启用",
|
||||
field_mapping_summary="产品名称 / 规格 / 风险等级",
|
||||
is_active=True,
|
||||
)
|
||||
|
||||
context = get_platform_demo_context()
|
||||
|
||||
assert context["owner_mappings"][0]["owner_name"] == "周八"
|
||||
assert context["feishu_configs"][0]["config_name"] == "数据库通知配置"
|
||||
assert context["template_mappings"][0]["template_name"] == "数据库模板"
|
||||
|
||||
|
||||
def test_governance_models_are_registered_in_admin():
|
||||
assert OwnerMapping in admin.site._registry
|
||||
assert FeishuNotifyConfig in admin.site._registry
|
||||
assert WordTemplateMapping in admin.site._registry
|
||||
|
||||
Reference in New Issue
Block a user