Skip to content

Commit

Permalink
更新编码风格
Browse files Browse the repository at this point in the history
  • Loading branch information
wu-clan committed Mar 11, 2024
1 parent 660d7ba commit c2437f5
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 37 deletions.
4 changes: 2 additions & 2 deletions httpfpt/core/conf.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ proxies.https = ''
send = false

# 企业微信
[wechat_talk]
[wechat]
webhook = ''
proxies.http = ''
proxies.https = ''
send_report = false
send = false


# 请求发送
Expand Down
14 changes: 7 additions & 7 deletions httpfpt/core/get_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,16 @@ def __init__(self) -> None:
self.FEISHU_SEND = glom(self.__config, 'feishu.send')

# 企业微信
self.WECHAT_TALK_WEBHOOK = glom(self.__config, 'wechat_talk.webhook')
self.WECHAT_TALK_PROXY = {
'http': glom(self.__config, 'wechat_talk.proxies.http')
if glom(self.__config, 'wechat_talk.proxies.http') != ''
self.WECHAT_WEBHOOK = glom(self.__config, 'wechat.webhook')
self.WECHAT_PROXY = {
'http': glom(self.__config, 'wechat.proxies.http')
if glom(self.__config, 'wechat.proxies.http') != ''
else None,
'https': glom(self.__config, 'wechat_talk.proxies.https')
if glom(self.__config, 'wechat_talk.proxies.https') != ''
'https': glom(self.__config, 'wechat.proxies.https')
if glom(self.__config, 'wechat.proxies.https') != ''
else None,
}
self.WECHAT_TALK_REPORT_SEND = glom(self.__config, 'wechat_talk.send_report')
self.WECHAT_SEND = glom(self.__config, 'wechat.send')

# 请求发送
self.REQUEST_TIMEOUT = glom(self.__config, 'request.timeout')
Expand Down
6 changes: 3 additions & 3 deletions httpfpt/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from httpfpt.utils.send_report.dingding import DingDing
from httpfpt.utils.send_report.email import SendEmail
from httpfpt.utils.send_report.feishu import FeiShu
from httpfpt.utils.send_report.wechat import Wechat
from httpfpt.utils.send_report.wechat import WeChat
from httpfpt.utils.time_control import get_current_time


Expand Down Expand Up @@ -140,8 +140,8 @@ def startup(
if config.FEISHU_SEND:
FeiShu(test_result).send()

if config.WECHAT_TALK_REPORT_SEND:
Wechat(test_result).send()
if config.WECHAT_SEND:
WeChat(test_result).send()

if allure:
if not os.path.exists(ALLURE_REPORT_ENV_FILE):
Expand Down
38 changes: 13 additions & 25 deletions httpfpt/utils/send_report/wechat.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from httpfpt.core.get_conf import config


class Wechat:
class WeChat:
def __init__(self, content: dict):
self.content = content

Expand All @@ -18,35 +18,23 @@ def send(self) -> None:
data = {
'msgtype': 'markdown',
'markdown': {
"content": "# {}\n"
"> 👤 测试人员:**{}**\n"
"> 🤖 测试结果:**{}**\n"
"> ✅ 通过用例: <font color='info'>**{}**</font>\n"
"> 🔧 失败用例: <font color='warning'>**{}**</font>\n"
"> ❌ 错误用例: **{}**\n"
"> ⚠️ 跳过用例: **{}**\n"
"> 🈴 总数用例: **{}**\n"
"> ⌛ 开始时间: **{}**\n"
"> ⏱️ 执行耗时: **{}**\n"
"> ➡️ 查看报告: [点击跳转](https://foryourself)".format(
config.TEST_REPORT_TITLE,
config.TESTER_NAME,
self.content["result"],
self.content["passed"],
self.content['failed'],
self.content['error'],
self.content['skipped'],
self.content['total'],
self.content['started_time'],
self.content['elapsed'],
)
'content': f"# {config.TEST_REPORT_TITLE}\n"
f"> 👤 测试人员: **{config.TESTER_NAME}**\n"
f"> 🤖 测试结果: **{self.content['result']}**\n"
f"> ✅ 通过用例: <font color='info'>**{self.content['passed']}**</font>\n"
f"> 🔧 失败用例: **{self.content['failed']}**\n"
f"> ❌ 错误用例: **{self.content['error']}**\n"
f"> ⚠️ 跳过用例: **{self.content['skipped']}**\n"
f"> ⌛ 开始时间: **{self.content['started_time']}**\n"
f"> ⏱️ 执行耗时: **{self.content['elapsed']}**\n"
"> ➡️ 查看报告: [点击跳转](https://foryourself)"
},
}
response = requests.session().post(
url=config.WECHAT_TALK_WEBHOOK,
url=config.WECHAT_WEBHOOK,
json=data,
headers=headers,
proxies=config.WECHAT_TALK_PROXY, # type: ignore
proxies=config.WECHAT_PROXY, # type: ignore
)
response.raise_for_status()
except Exception as e:
Expand Down

0 comments on commit c2437f5

Please sign in to comment.