-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(transformer): dingtalk_to_feishu support markdown type
- Loading branch information
Showing
2 changed files
with
49 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,51 @@ | ||
import os | ||
import unittest | ||
|
||
import requests | ||
|
||
feishu_webhook = os.getenv("TRUMPET_FEISHU_WEBHOOK") | ||
dingtalk_webhook = os.getenv("TRUMPET_DINGTALK_WEBHOOK") | ||
|
||
# https://ding-doc.dingtalk.com/doc#/serverapi2/qf2nxq | ||
# https://www.feishu.cn/hc/zh-cn/articles/360024984973-%E5%9C%A8%E7%BE%A4%E8%81%8A%E4%B8%AD%E4%BD%BF%E7%94%A8%E6%9C%BA%E5%99%A8%E4%BA%BA | ||
resp = requests.post( | ||
f"http://127.0.0.1:8080/transformers/dingtalk_to_feishu?trumpet_to={feishu_webhook}", | ||
json={"msgtype": "text", "text": {"content": "快乐小神仙"}}, | ||
) | ||
print(resp.status_code) | ||
print(resp.headers) | ||
print(resp.text) | ||
|
||
resp = requests.post( | ||
f"http://127.0.0.1:8080/transformers/feishu_to_dingtalk?trumpet_to={dingtalk_webhook}", | ||
json={"msg_type": "text", "content": {"text": "快乐小神仙"}}, | ||
) | ||
print(resp.status_code) | ||
print(resp.headers) | ||
print(resp.text) | ||
|
||
|
||
class TestStringMethods(unittest.TestCase): | ||
def test_dingtalk_to_feishu(self): | ||
url = f"http://127.0.0.1:8080/transformers/dingtalk_to_feishu?trumpet_to={feishu_webhook}" | ||
cases = [ | ||
{"msgtype": "text", "text": {"content": "快乐小神仙"}}, | ||
{ | ||
"markdown": { | ||
"title": "哈哈哈 触发了 job test, 构建号:620", | ||
"text": "###### 项目 [Unob](https://coding.net/p/unob)\n[哈哈哈](https://coding.net/u/ljaSkNTntD) 触发了 job \n> [test](https://coding.net/p/unob/ci/job/260491) 构建号:[620](https://coding.net/p/proj/ci/job/260491/build/620/pipeline)", | ||
}, | ||
"msgtype": "markdown", | ||
}, | ||
{ | ||
"markdown": { | ||
"text": "###### 项目 [Unob](https://coding.net/p/unob)\n[哈哈哈](https://coding.net/u/ljaSkNTntD) 触发了 job \n> [test](https://coding.net/p/unob/ci/job/260491) 构建号:[620](https://coding.net/p/proj/ci/job/260491/build/620/pipeline)", | ||
}, | ||
"msgtype": "markdown", | ||
}, | ||
] | ||
for case in cases: | ||
resp = requests.post(url, json=case) | ||
print(resp.status_code) | ||
print(resp.headers) | ||
print(resp.text) | ||
assert resp.ok | ||
|
||
def test_feishu_to_dingtalk(self): | ||
url = f"http://127.0.0.1:8080/transformers/feishu_to_dingtalk?trumpet_to={dingtalk_webhook}" | ||
cases = [{"msg_type": "text", "content": {"text": "快乐小神仙"}}] | ||
for case in cases: | ||
resp = requests.post(url, json=case) | ||
print(resp.status_code) | ||
print(resp.headers) | ||
print(resp.text) | ||
assert resp.ok | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters