test: 钉住 deep_merge 的 None 替换与列表替换语义 + 只读约定注释

- characterization:显式 None 整体替换且兄弟键保留默认(Task 9 回退契约依赖);列表整体替换不与默认拼接
- DEFAULT_CONFIG 与 TenantConfig.data/Site.brand 补只读约定注释
- platform 包依赖章程改明确:defaults/tenant_config 为叶子模块供 engine 反向消费,registry 组装层可 import app/engine

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
浅念
2026-10-12 16:59:31 +08:00
parent 89339868db
commit 8a16a2959b
4 changed files with 27 additions and 4 deletions
+19
View File
@@ -66,3 +66,22 @@ def test_tenant_without_sites():
assert tenant.status == "active"
assert tenant.data["ai"]["model"] == "glm-4-plus" # 覆盖生效
assert tenant.data["push"]["enabled"] is False # 缺省补齐
# ---------- characterization:None / 列表整体替换语义 ----------
def test_explicit_none_replaces_and_keeps_sibling():
"""显式 None 整体替换该键;兄弟键保留默认。
Task 9 的回退契约依赖此语义:快照里显式写 null 表示"清空/未设置",
不能被解读为"回落默认值"。
"""
merged = deep_merge(DEFAULT_CONFIG, {"ai": {"api_key": None}})
assert merged["ai"]["api_key"] is None # 显式 None 生效
assert merged["ai"]["model"] == "glm-4-flash" # 兄弟键保留默认
def test_list_replaced_wholesale():
"""列表整体替换,不与默认值拼接。"""
merged = deep_merge(DEFAULT_CONFIG, {"email": {"notify_emails": ["x@y.z"]}})
assert merged["email"]["notify_emails"] == ["x@y.z"]