Commit 19c095be authored by zhanhuasheng's avatar zhanhuasheng

bugfix

parent 54db255b
import subprocess
import requests
import time
import hmac
......@@ -29,10 +31,11 @@ class webhookHandler:
"msgtype": "markdown",
"markdown": {
"title":"#willdesk接口自动化测试报告",
"text": "#### 本次接口自动化测试结果如下 \n > ###### 用例总数:%s\n > ###### 成功用例数量:%s\n > ###### 失败用例数量:%s\n > ###### 报错用例数量:%s\n > ###### 跳过用例数量:%s \n > ###### 耗时:%s秒\n > ###### 报告生成时间:%s [测试报告](https://www.baidu.com)"%(result._numcollected,len(result.stats.get('passed', [])),len(result.stats.get('failed', [])),len(result.stats.get('error', [])),len(result.stats.get('skipped', [])),second,current_date_time_str)
"text": "#### 本次接口自动化测试结果如下 \n > ###### 用例总数:%s\n > ###### 成功用例数量:%s\n > ###### 失败用例数量:%s\n > ###### 报错用例数量:%s\n > ###### 跳过用例数量:%s \n > ###### 耗时:%s秒\n > ###### 报告生成时间:%s [测试报告](%s)"%(result._numcollected,len(result.stats.get('passed', [])),len(result.stats.get('failed', [])),len(result.stats.get('error', [])),len(result.stats.get('skipped', [])),second,current_date_time_str,self.get_local_ip_address())
},
}
res = requests.post(url=self.webhookUrl,json=data)
# print(res.json())
def sendMsg(self,title,text):
......@@ -45,5 +48,18 @@ class webhookHandler:
}
res = requests.post(url=self.webhookUrl,data=data)
def get_local_ip_address(self):
cmd = 'ifconfig'
result = subprocess.run(cmd,capture_output=True,text=True,shell=True)
output = result.stdout
ip = None
for line in output.split('\n'):
if 'inet ' in line and '127.0.0.1' not in line:
ip = line.split(' ')[1]
break
if ip:
ip = ip + ':8000/report.html'
else:
ip = 'https://www.baidu.com'
return ip
webhook = webhookHandler()
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment