Files
apiautotest/config/settings.py

226 lines
10 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# -*- coding: utf-8 -*-
# @Version: Python 3.9
# @Time : 2023/1/9 17:08
# @Author : chenyinhua
# @File : settings.py
# @Software: PyCharm
# @Desc: 项目配置文件
# ------------------------------------ 测试数据配置 ----------------------------------------------------#
ENV_VARS = {
"common": {
"报告标题": "API 自动化测试报告",
"项目名称": "GitLink 确实开源",
"tester": "陈银花",
"department": "开源中心",
"env": ""
},
"test": {
# 示例测试环境及示例测试账号
"host": "https://testforgeplus.trustie.net",
"client_id": "****client_id-test****", # 获取oauth_token需要的参数
"client_secret": "****client_secret-test****", # 获取oauth_token需要的参数
"green_code": "****green_code-test****", # 万能验证码
"login": "autotest",
"password": "****autotest-test****", # 运行时需要手动更改密码
"nickname": "autotest",
"user_id": 106,
"super_login": "floraachy",
"super_password": "****floraachy-test****", # 运行时需要手动更改密码
"project_url": "/autotest/auotest",
"db_info": {
"db_host": "xx.xx.xx.xx",
"db_port": 3306,
"db_user": "root",
"db_pwd": "**********",
"db_database": "test**********",
"ssh": False,
"ssh_host": "xx.xx.xx.xx",
"ssh_port": 3306,
"ssh_user": "root",
"ssh_pwd": "**********"
}
},
"pre": {
# 示例测试环境及示例测试账号
"host": "http://172.20.32.202:4000",
"client_id": "****client_id-pre****", # 获取oauth_token需要的参数
"client_secret": "****client_secret-pre****", # 获取oauth_token需要的参数
"green_code": "****green_code-pre****", # 万能验证码
"login": "autotest",
"password": "****autotest-pre****", # 运行时需要手动更改密码
"nickname": "autotest",
"user_id": 115,
"super_login": "floraachy",
"super_password": "****floraachy-pre****", # 运行时需要手动更改密码
"project_url": "/floraachy/autotest",
"db_info": {
"db_host": "xx.xx.xx.xx",
"db_port": 3306,
"db_user": "root",
"db_pwd": "**********",
"db_database": "test**********",
"ssh": False,
"ssh_host": "xx.xx.xx.xx",
"ssh_port": 3306,
"ssh_user": "root",
"ssh_pwd": "**********"
}
},
"live": {
"host": "https://www.gitlink.org.cn",
"client_id": "****client_id-live****", # 获取oauth_token需要的参数
"client_secret": "****client_secret-live****", # 获取oauth_token需要的参数
"green_code": "****green_code-live****", # 万能验证码
"login": "floraachy",
"password": "****floraachy-live****", # 运行时需要手动更改密码
"nickname": "🌼陈银花",
"user_id": 87611,
"super_login": "chenyh",
"super_password": "****chenyh-live****", # 运行时需要手动更改密码
"project_url": "/floraachy/auotest",
"db_info": {
"db_host": "xx.xx.xx.xx",
"db_port": 3306,
"db_user": "root",
"db_pwd": "**********",
"db_database": "test**********",
"ssh": True,
"ssh_host": "xx.xx.xx.xx",
"ssh_port": 3306,
"ssh_user": "root",
"ssh_pwd": "**********"
}
}
}
# ------------------------------------ pytest相关配置 ----------------------------------------------------#
class RunConfig:
"""
运行测试配置
"""
# 失败重跑次数
rerun = 0
# 失败重跑间隔时间
reruns_delay = 5
# 当达到最大失败数,停止执行
max_fail = "10"
# ------------------------------------ 配置信息 ----------------------------------------------------#
# 0代表执行Excel和yaml两种格式的用例 1 代表 yaml文件2 用例代表Excel用例 其他数值将不自动生成用例,仅能执行手动编写的用例
CASE_FILE_TYPE = 1
# 0表示默认不发送任何通知 1 代表钉钉通知2 代表企业微信通知, 3 代表邮件通知, 4 代表所有途径都发送通知
SEND_RESULT_TYPE = 0
# 指定日志收集级别
LOG_LEVEL = "DEBUG" # 可选值TRACE DEBUG INFO SUCCESS WARNING ERROR CRITICAL
"""
支持的日志级别:
TRACE: 最低级别的日志级别,用于详细追踪程序的执行。
DEBUG: 用于调试和开发过程中打印详细的调试信息。
INFO: 提供程序执行过程中的关键信息。
SUCCESS: 用于标记成功或重要的里程碑事件。
WARNING: 表示潜在的问题或不符合预期的情况,但不会导致程序失败。
ERROR: 表示错误和异常情况,但程序仍然可以继续运行。
CRITICAL: 表示严重的错误和异常情况,可能导致程序崩溃或无法正常运行。
"""
# ------------------------------------ 邮件配置信息 ----------------------------------------------------#
# 发送邮件的相关配置信息
email = {
"user": "****email-user****", # 发件人邮箱
"password": "****email-password****", # 发件人邮箱授权码
"host": "smtp.qq.com",
"to": ["****email-user-1****", "****email-user-2****"] # 收件人邮箱
}
# ------------------------------------ 邮件通知内容 ----------------------------------------------------#
email_subject = f"UI自动化报告"
email_content = """
各位同事, 大家好:
自动化用例于 <strong>${start_time} </strong> 开始运行,运行时长:<strong>${run_time} s</strong> 目前已执行完成。
---------------------------------------------------------------------------------------------------------------
测试人:<strong> ${tester} </strong>
所属部门:<strong> ${department} </strong>
项目环境:<strong> ${env} </strong>
---------------------------------------------------------------------------------------------------------------
执行结果如下:
&nbsp;&nbsp;用例运行总数:<strong> ${total} 个</strong>
&nbsp;&nbsp;通过用例个数passed: <strong><font color="green" >${passed} 个</font></strong>
&nbsp;&nbsp;失败用例个数failed: <strong><font color="red" >${failed} 个</font></strong>
&nbsp;&nbsp;异常用例个数error: <strong><font color="orange" >${broken} 个</font></strong>
&nbsp;&nbsp;跳过用例个数skipped: <strong><font color="grey" >${skipped} 个</font></strong>
&nbsp;&nbsp;失败重试用例个数 * 次数之和rerun: <strong>${rerun} 个</strong>
&nbsp;&nbsp;成 功 率:<strong> <font color="green" >${pass_rate} %</font></strong>
**********************************
附件为具体的测试报告,详细情况可下载附件查看, 非相关负责人员可忽略此消息。谢谢。
"""
# ------------------------------------ 钉钉相关配置 ----------------------------------------------------#
ding_talk = {
"webhook_url": "https://oapi.dingtalk.com/robot/send?access_token=********",
"secret": "****ding****"
}
# ------------------------------------ 钉钉通知内容 ----------------------------------------------------#
ding_talk_title = f"UI自动化报告"
ding_talk_content = """
各位同事, 大家好:
### 自动化用例于 ${start_time} 开始运行,运行时长:${run_time} s 目前已执行完成。
---------------------------------------------------------------------------------------------------------------
#### 测试人: ${tester}
#### 所属部门: ${department}
#### 项目环境: ${env}
---------------------------------------------------------------------------------------------------------------
#### 执行结果如下:
- 用例运行总数: ${total}
- 通过用例个数passed: ${passed}
- 失败用例个数failed: ${failed}
- 异常用例个数error: ${broken}
- 跳过用例个数skipped: ${skipped}
- 失败重试用例个数 * 次数之和rerun: ${rerun}
- 成 功 率: ${pass_rate} %
**********************************
附件为具体的测试报告,详细情况可下载附件查看, 非相关负责人员可忽略此消息。谢谢。
"""
# ------------------------------------ 企业微信相关配置 ----------------------------------------------------#
wechat = {
"webhook_url": "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=********",
}
# ------------------------------------ 企业微信通知内容 ----------------------------------------------------#
wechat_content = """
各位同事, 大家好:
### 自动化用例于 ${start_time} 开始运行,运行时长:${run_time} s 目前已执行完成。
--------------------------------
#### 测试人: ${tester}
#### 所属部门: ${department}
#### 项目环境: ${env}
--------------------------------
#### 执行结果如下:
- 用例运行总数: ${total}
- 通过用例个数passed:<font color=\"info\"> ${passed} 个</font>
- 失败用例个数failed: <font color=\"warning\"> ${failed} 个</font>
- 异常用例个数error: <font color=\"warning\"> ${broken} 个</font>
- 跳过用例个数skipped: <font color=\"comment\"> ${skipped} 个</font>
- 失败重试用例个数 * 次数之和rerun: <font color=\"comment\"> ${rerun} 个</font>
- 成 功 率: <font color=\"info\"> ${pass_rate} % </font>
**********************************
附件为具体的测试报告,详细情况可下载附件查看, 非相关负责人员可忽略此消息。谢谢。
"""