Commit 0db045b0 authored by huangqiang's avatar huangqiang

增加发送邮件

parent ac4e868b
......@@ -34,7 +34,6 @@ def update_address(address: list):
print("未输入IP地址,使用默认IP地址")
# 获取时间格式名称
def get_time_name() -> list:
names = []
......@@ -61,7 +60,7 @@ def readconf(section, option):
def get_case_path(section):
values = []
cf = configparser.ConfigParser()
cf.read("config.conf", encoding="utf-8")
cf.read("run.conf", encoding="utf-8")
if cf.has_section(section):
items = cf.items(section)
for item in items:
......
......@@ -9,7 +9,7 @@ reportpath = report/
web_hook = https://oapi.dingtalk.com/robot/send?access_token=94b76afb5b538437e9986e95bd9e4c882cfcf3c75e8c1b3a6f209cac403b8e00
[token]
token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1aWQiOiIyNTc0ODgiLCJ0ZXJtaW5hbCI6InBjIiwidXVpZCI6Ijg2OTE0YzkzNDQwYjQ5OTE5NGNkOGZiNTI4NTE2MWQ3IiwidGltZXN0YW1wIjoxNTc0NDA4NjQ3MDIwfQ.zT32vh1ZIc7iwKnZAaS452-oyMjQB5JUAhTeyCo9PFM
token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1aWQiOiIyNTc0ODgiLCJ0ZXJtaW5hbCI6InBjIiwidXVpZCI6IjIwNDFlZmNjNWNmZjRlNTlhZTkzNWY0YjhkODQ3MzhlIiwidGltZXN0YW1wIjoxNTc0NjY2NjQwODU3fQ._G5B9sI238xlT6sAkJ3ou15Qj3HXUIleF4UhJ48YdeY
[password]
wan_neng_password = A0S7f14f94e7-dcc
......@@ -18,6 +18,10 @@ wan_neng_password = A0S7f14f94e7-dcc
phone = 15300000000
password = Abc123!
[test]
student_new = reception/testsuites/apply_stuent_new.yml
[email]
host = smtp.exmail.qq.com
port = 465
from_adress = huangqiang1@jiuaoedu.com
password = JhyC5M5rCtfBGsab
to_adresses = huangqiang1@jiuaoedu.com,mzx6010@dingtalk.com
......@@ -50,12 +50,13 @@ def send_dingding_message(web_hook,msg,message_type="text",is_at_all=False,at_mo
return result
def get_markdown_template()-> str:
markdown_template = """"
markdown_template = """
接口测试概要(${host})\n
整体结果: ${result}\n
是否成功: ${result}\n
测试开始时间:${start_datetime}
持续时间:${duration_time}\n
测试用例总数:${testcases_total},成功:${testcases_success},失败:${testcases_fail}\n
测试用例总数:${testcases_total},成功:${testcases_success},失败:${testcases_fail}
(登录时为测试的账户数)\n
测试调用接口总数:${teststep_total},成功:${teststep_success},失败:${teststep_failures},跳过:${teststep_skipped},错误:${teststep_errors}
"""
return markdown_template
......
......@@ -4,13 +4,13 @@ import sys
import dingdingmessage
import common
import getdata
from sendemail import SendEmail
def run():
report_path = common.readconf("path", "reportpath")
logfile_name = common.get_time_name()[0] + "_test.log"
logfile_name = common.get_time_name()[0] + "_interface_test.log"
log_path = common.readconf("path", "logpath") + logfile_name
report_name = common.get_time_name()[1] + "_test.html"
report_name = common.get_time_name()[1] + "_interface_test.html"
runner = HttpRunner(report_dir=report_path, log_level="INFO",
log_file=log_path, report_file=report_name, failfast=True)
......@@ -21,8 +21,13 @@ def run():
# mapping=override_mapping
for test_case_path in path_or_testcases:
runner.run(test_case_path)
# dingdingmessage.send_result_message(runner.summary)
dingdingmessage.send_result_message(runner.summary)
send_email = SendEmail()
subject = common.get_time_name()[0] + "接口测试报告"
attachments = []
attachment = "report/" + report_name
attachments.append(attachment)
send_email.send_email(subject, "详情请下载查看附件", attachments=attachments)
if __name__ == "__main__":
......
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