feat: 支持按项目配置钉钉通知 @ 名单
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
a4cd855b0c
commit
10c39b5116
@@ -142,3 +142,21 @@ def test_dingtalk_notification_sends_markdown():
|
||||
def test_dingtalk_notification_requires_webhook_when_enabled():
|
||||
with pytest.raises(NotificationError, match="Webhook"):
|
||||
send_dingtalk_notification({"enabled": True}, _build_config(), "https://download.example.com/app")
|
||||
|
||||
|
||||
def test_project_at_mobiles_override_global_per_build_type():
|
||||
from backend.services.notification import merge_project_at_mobiles
|
||||
|
||||
global_config = {"enabled": True, "at_mobiles": ["111"], "at_mobiles_app_store": ["222"]}
|
||||
merged = merge_project_at_mobiles(global_config, {"at_mobiles": ["333", "333", " "], "at_mobiles_app_store": []})
|
||||
|
||||
assert merged["at_mobiles"] == ["333"]
|
||||
assert merged["at_mobiles_app_store"] == ["222"] # 项目未配置,沿用全局
|
||||
assert global_config["at_mobiles"] == ["111"] # 不修改全局配置
|
||||
|
||||
|
||||
def test_project_at_mobiles_missing_keeps_global():
|
||||
from backend.services.notification import merge_project_at_mobiles
|
||||
|
||||
global_config = {"at_mobiles": ["111"]}
|
||||
assert merge_project_at_mobiles(global_config, None) == global_config
|
||||
|
||||
@@ -328,3 +328,20 @@ def test_generic_patcher_replace_line_rule(dy_build_dir):
|
||||
apply_project_config(dy_build_dir, _dy_config(), project)
|
||||
macro = (dy_build_dir / "DyAuction" / "Public" / "DyConstantsMacro.h").read_text()
|
||||
assert '#define APPCHEME @"cn.touchv.auction2"' in macro
|
||||
|
||||
|
||||
def test_project_dingtalk_at_saved_and_returned(client, dy_project, tmp_config):
|
||||
resp = client.put("/api/config/projects/dyauction",
|
||||
json={"dingtalk_at": {"at_mobiles": "13800000001,13800000002\n13800000001"}})
|
||||
assert resp.status_code == 200, resp.text
|
||||
dy = _root(tmp_config)["projects"]["dyauction"]
|
||||
assert dy["dingtalk_at"] == {"at_mobiles": ["13800000001", "13800000002"], "at_mobiles_app_store": []}
|
||||
|
||||
listed = {p["id"]: p for p in client.get("/api/config/projects").json()}
|
||||
assert listed["dyauction"]["dingtalk_at"]["at_mobiles"] == ["13800000001", "13800000002"]
|
||||
assert listed["readoor"]["dingtalk_at"] == {"at_mobiles": [], "at_mobiles_app_store": []}
|
||||
|
||||
|
||||
def test_project_dingtalk_at_must_be_object(client, dy_project):
|
||||
resp = client.put("/api/config/projects/dyauction", json={"dingtalk_at": ["138"]})
|
||||
assert resp.status_code == 400
|
||||
|
||||
Reference in New Issue
Block a user