Commit 6b07ee8f by mc183225678

接口自动化框架V3

parent ca3afc65
......@@ -7,6 +7,6 @@
# Description:
#
# ---------------------------------------------------------------------------
from InterfaceAutoTest.common.log import write_log
from InterfaceAutoTest_v3.common.log import write_log
log = write_log()
......@@ -9,9 +9,9 @@
# ---------------------------------------------------------------------------
import pymysql
from InterfaceAutoTest.common import log
from InterfaceAutoTest.common.read_ini import ReadIni
from InterfaceAutoTest.data_config.settings import *
from InterfaceAutoTest_v3.common import log
from InterfaceAutoTest_v3.common.read_ini import ReadIni
from InterfaceAutoTest_v3.data_config.settings import *
class DB:
......
......@@ -7,31 +7,44 @@
# Description:
#
# ---------------------------------------------------------------------------
import os
import openpyxl
from InterfaceAutoTest.data_config.settings import *
from InterfaceAutoTest.common import log
from InterfaceAutoTest.common.read_ini import ReadIni
from InterfaceAutoTest.common.read_json import read_json
from InterfaceAutoTest_v3.data_config.settings import *
from InterfaceAutoTest_v3.common import log
from InterfaceAutoTest_v3.common.read_ini import ReadIni
from InterfaceAutoTest_v3.common.read_json import read_json
class ReadExcel:
def __init__(self, table_nme, excel_path=None):
def __init__(self, table_name, excel_name, case_data_name, expect_data_name, sql_data_name=None):
"""获取数据配置层中除了ini文件以外的所有文件的路径,再获取excel的工作表,再读取所有的json文件"""
self.read_ini = ReadIni()
# 单数据文件--单用户
"""
excel_path = self.read_ini.get_file_path(EXCEL)
case_data_path = self.read_ini.get_file_path(CASE)
expect_data_path = self.read_ini.get_file_path(EXPECT)
sql_data_path = self.read_ini.get_file_path(SQL)
# 获取工作表名称
# table_name = self.read_ini.get_table_name(TABLE_NAME)
table_name = table_nme
wb = openpyxl.load_workbook(excel_path)
"""
# 多数据文件--多用户
excel_path = os.path.join(self.read_ini.data_config_path, excel_name)
case_data_path = os.path.join(self.read_ini.data_config_path, case_data_name)
expect_data_path = os.path.join(self.read_ini.data_config_path, expect_data_name)
if sql_data_name is not None:
sql_data_path = os.path.join(self.read_ini.data_config_path, sql_data_name)
# table_name = table_name
try:
self.wb = openpyxl.load_workbook(excel_path)
except:
log.error("excel文件的路径错误")
try:
self.ws = wb[table_name]
self.ws = self.wb[table_name]
except:
log.error("获取工作表失败,请察看工作表名称是否配置正确!!!")
raise KeyError("获取工作表失败,请察看工作表名称是否配置正确!!!")
......@@ -170,5 +183,7 @@ class ReadExcel:
if __name__ == '__main__':
excel = ReadExcel()
print(excel.get_data())
\ No newline at end of file
# excel = ReadExcel()
# print(excel.get_data())
print(ReadExcel("BPM-laohuang", "laohuang/APIAutoTest.xlsx", "laohuang/case_data.json", "laohuang/expect_data.json",
"laohuang/sql_data.json").get_data())
\ No newline at end of file
......@@ -9,8 +9,8 @@
# ---------------------------------------------------------------------------
import configparser
import os
from InterfaceAutoTest.common import log
from InterfaceAutoTest.data_config.settings import *
from InterfaceAutoTest_v3.common import log
from InterfaceAutoTest_v3.data_config.settings import *
class ReadIni:
......
......@@ -9,7 +9,7 @@
# ---------------------------------------------------------------------------
import json
import os
from InterfaceAutoTest.common import log
from InterfaceAutoTest_v3.common import log
def read_json(filename):
......
{
"认证接口":{
"登录系统":{
"LoginSuccess": {"password": "MTIzNDU2","username": "admin"},
"LoginErrorUsernameLong":{"password": "MTIzNDU2","username": "adminadminadminadminadminadmin"},
"LoginErrorUsernameShort":{"password": "MTIzNDU2","username": "a"},
"LoginErrorUsernameNone":{"password": "MTIzNDU2","username": ""},
"LoginErrorUsernameSpecial":{"password": "MTIzNDU2","username": "@#!@#!@"},
"LoginErrorPwdLong":{"password": "MTIzNDU2MTIzNDU2MTIzNDU2MTIzNDU2MTIzNDU2","username": "admin"},
"LoginErrorPwdShort":{"password": "m","username": "admin"},
"LoginErrorPwdNone":{"password": "","username": "admin"},
"LoginErrorPwdSpecial":{"password": "@#!@#!@","username": "admin"},
"LoginErrorPwdError":{"password": "MTIzNDU222","username": "admin"}
}
},
"维度管理": {
"添加维度": {
"AddDemSuccess": {
"code": "dem_test57_abc",
"description": "测试维度57",
"isDefault": 0,
"name": "测试57期的维度"
}
},
"根据维度编码获取维度信息": {
"GetDemMessageSuccess": {"code": "dem_test57_abc"}
},
"根据维度编码删除维度": {
"DeleteDemSuccess": {"ids": "不知道"}
}
},
"组织管理": {
"添加组织": {
"AddOrgSuccess": {
"code": "test_org_57",
"demId": "不知道",
"exceedLimitNum": 0,
"grade": "",
"limitNum": 0,
"name": "测试组织",
"nowNum": 0,
"orderNo": 0,
"parentId": "0"
}
},
"添加组织参数": {
"AddOrgParamsSuccess": {"query": {"orgCode": "test_org_57"}, "body": [{"alias":"sz","value":9000}]}
},
"删除组织": {
"DelOrgSuccess": "test_org_57"
}
}
}
{
"认证接口":{
"登录系统":{
"LoginSuccess": {"username": "超级管理","account": "admin", "loginStatus": true},
"LoginErrorUsernameLong":{"state": false, "message":"账号或密码错误"},
"LoginErrorUsernameShort":{"state": false, "message":"账号或密码错误"},
"LoginErrorUsernameNone":{"state": false, "message":"账号或密码错误"},
"LoginErrorUsernameSpecial":{"state": false, "message":"账号或密码错误"},
"LoginErrorPwdLong":{"state": false, "message":"账号或密码错误"},
"LoginErrorPwdShort":{"state": false, "message":"账号或密码错误"},
"LoginErrorPwdNone":{"state": false, "message":"账号或密码错误"},
"LoginErrorPwdSpecial":{"state": false, "message":"账号或密码错误"},
"LoginErrorPwdError":{"state": false, "message":"账号或密码错误"}
},
"刷新token": {
"RefreshSuccess": {"message": "刷新成功"}
}
},
"维度管理": {
"添加维度": {
"AddDemSuccess": {"state": true, "message": "添加维度成功!"}
},
"根据维度编码获取维度信息": {
"GetDemMessageSuccess": {"demCode": "dem_test57_abc", "name": "测试57期的维度"}
},
"根据维度编码删除维度": {
"DeleteDemSuccess": {"state": true, "message": "删除维度成功"}
}
},
"组织管理": {
"添加组织": {
"AddOrgSuccess": {"state": true, "message": "添加组织成功!"}
},
"添加组织参数": {
"AddOrgParamsSuccess": {"state":true,"message":"保存组织参数成功!"}
},
"删除组织": {
"DelOrgSuccess": {"state":true,"message":"删除组织成功!"}
}
}
}
\ No newline at end of file
{
"维度管理": {
"添加维度": {
"AddDemSuccess": "DELETE FROM uc_demension WHERE `CODE_`=\"dem_test57_abc\";"
},
"根据维度编码删除维度": {
"DeleteDemSuccess": "SELECT ID_ from uc_demension WHERE `CODE_`=\"dem_test57_abc\";"
}
},
"组织管理": {
"添加组织": {
"AddOrgSuccess": {
"select": "SELECT ID_ from uc_demension WHERE `CODE_`=\"dem_test57_abc\";",
"delete": "DELETE FROM uc_org WHERE `CODE_`=\"test_org_57\";"
}
}
}
}
\ No newline at end of file
{
"认证接口":{
"登录系统":{
"LoginSuccess": {"password": "MTIzNDU2","username": "admin"},
"LoginErrorUsernameLong":{"password": "MTIzNDU2","username": "adminadminadminadminadminadmin"},
"LoginErrorUsernameShort":{"password": "MTIzNDU2","username": "a"},
"LoginErrorUsernameNone":{"password": "MTIzNDU2","username": ""},
"LoginErrorUsernameSpecial":{"password": "MTIzNDU2","username": "@#!@#!@"},
"LoginErrorPwdLong":{"password": "MTIzNDU2MTIzNDU2MTIzNDU2MTIzNDU2MTIzNDU2","username": "admin"},
"LoginErrorPwdShort":{"password": "m","username": "admin"},
"LoginErrorPwdNone":{"password": "","username": "admin"},
"LoginErrorPwdSpecial":{"password": "@#!@#!@","username": "admin"},
"LoginErrorPwdError":{"password": "MTIzNDU222","username": "admin"}
}
},
"维度管理": {
"添加维度": {
"AddDemSuccess": {
"code": "dem_test57_abc",
"description": "测试维度57",
"isDefault": 0,
"name": "测试57期的维度"
}
},
"根据维度编码获取维度信息": {
"GetDemMessageSuccess": {"code": "dem_test57_abc"}
},
"根据维度编码删除维度": {
"DeleteDemSuccess": {"ids": "不知道"}
}
},
"组织管理": {
"添加组织": {
"AddOrgSuccess": {
"code": "test_org_57",
"demId": "不知道",
"exceedLimitNum": 0,
"grade": "",
"limitNum": 0,
"name": "测试组织",
"nowNum": 0,
"orderNo": 0,
"parentId": "0"
}
},
"添加组织参数": {
"AddOrgParamsSuccess": {"query": {"orgCode": "test_org_57"}, "body": [{"alias":"sz","value":9000}]}
},
"删除组织": {
"DelOrgSuccess": "test_org_57"
}
}
}
{
"认证接口":{
"登录系统":{
"LoginSuccess": {"username": "超级管理","account": "admin", "loginStatus": true},
"LoginErrorUsernameLong":{"state": false, "message":"账号或密码错误"},
"LoginErrorUsernameShort":{"state": false, "message":"账号或密码错误"},
"LoginErrorUsernameNone":{"state": false, "message":"账号或密码错误"},
"LoginErrorUsernameSpecial":{"state": false, "message":"账号或密码错误"},
"LoginErrorPwdLong":{"state": false, "message":"账号或密码错误"},
"LoginErrorPwdShort":{"state": false, "message":"账号或密码错误"},
"LoginErrorPwdNone":{"state": false, "message":"账号或密码错误"},
"LoginErrorPwdSpecial":{"state": false, "message":"账号或密码错误"},
"LoginErrorPwdError":{"state": false, "message":"账号或密码错误"}
},
"刷新token": {
"RefreshSuccess": {"message": "刷新成功"}
}
},
"维度管理": {
"添加维度": {
"AddDemSuccess": {"state": true, "message": "添加维度成功!"}
},
"根据维度编码获取维度信息": {
"GetDemMessageSuccess": {"demCode": "dem_test57_abc", "name": "测试57期的维度"}
},
"根据维度编码删除维度": {
"DeleteDemSuccess": {"state": true, "message": "删除维度成功"}
}
},
"组织管理": {
"添加组织": {
"AddOrgSuccess": {"state": true, "message": "添加组织成功!"}
},
"添加组织参数": {
"AddOrgParamsSuccess": {"state":true,"message":"保存组织参数成功!"}
},
"删除组织": {
"DelOrgSuccess": {"state":true,"message":"删除组织成功!"}
}
}
}
\ No newline at end of file
{
"维度管理": {
"添加维度": {
"AddDemSuccess": "DELETE FROM uc_demension WHERE `CODE_`=\"dem_test57_abc\";"
},
"根据维度编码删除维度": {
"DeleteDemSuccess": "SELECT ID_ from uc_demension WHERE `CODE_`=\"dem_test57_abc\";"
}
},
"组织管理": {
"添加组织": {
"AddOrgSuccess": {
"select": "SELECT ID_ from uc_demension WHERE `CODE_`=\"dem_test57_abc\";",
"delete": "DELETE FROM uc_org WHERE `CODE_`=\"test_org_57\";"
}
}
}
}
\ No newline at end of file
2023-11-03 17:01:56,696 - test_bpm.py[line:50] - ERROR: 断言失败,用例数据为:{'password': 'MTIzNDU2', 'username': 'admin'},期望数据为:{'username': '超级管理', 'account': 'admin', 'loginStatus': True},服务器返回的数据为:{"token":"eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsInRlbmFudElkIjoiLTEiLCJleHAiOjE2OTkwODg1MTYsImlhdCI6MTY5OTAwMjExNn0.JD6c5pH4Zyq0BfXAUFgqaF7031irkSDjgTp8uvWRxoGuak6a7nfZ8F16vTz8aol-7WIl-C276JABeuGqvUhntg","username":"超级管理员","account":"admin","userId":"1","expiration":86400,"loginStatus":true,"userAttrs":{"tenantId":"-1"}} - 黄总
......@@ -324,3 +324,21 @@
2023-11-06 11:49:03,561 - test_bpm.py[line:59] - ERROR: 断言失败,用例数据为:{'password': 'MTIzNDU2', 'username': 'admin'},期望数据为:{'username': '超级管理', 'account': 'admin', 'loginStatus': True},服务器返回的数据为:{"token":"eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsInRlbmFudElkIjoiLTEiLCJleHAiOjE2OTkzMjg5NDQsImlhdCI6MTY5OTI0MjU0NH0.4y6er6hXCfF3A27H0Cci7p6zvL6fALMilj_xBfIxVhMU8ddr0COMKC6HI4GNR3Yo0f9AyJz8n-uzQi8bYjEPVA","username":"超级管理员","account":"admin","userId":"1","expiration":86400,"loginStatus":true,"userAttrs":{"tenantId":"-1"}} - 黄总
2023-11-06 11:49:04,632 - test_bpm.py[line:59] - ERROR: 断言失败,用例数据为:None,期望数据为:{'message': '刷新成功'},服务器返回的数据为:{"token":"eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsInRlbmFudElkIjoiLTEiLCJleHAiOjE2OTkzMjg5NDUsImlhdCI6MTY5OTI0MjU0NX0.D9YH4bKjttn74Fb7KgS3XsBEXhtn2PLXqwN0gGqSzWEDfjoN28Ql-b8awn-dHZrupnM26deD5k14as8ScKo2xg","username":"","account":"","userId":"","loginStatus":true,"userAttrs":{}} - 黄总
2023-11-06 11:49:05,219 - test_bpm.py[line:59] - ERROR: 断言失败,用例数据为:{'ids': '1721374116574937088'},期望数据为:{'state': True, 'message': '删除维度成功'},服务器返回的数据为:{"state":true,"message":"删除维度成功!","value":""} - 黄总
2023-11-08 11:13:07,680 - test_bpm_laohuang.py[line:63] - ERROR: 断言失败,用例数据为:{'password': 'MTIzNDU2', 'username': 'admin'},期望数据为:{'username': '超级管理', 'account': 'admin', 'loginStatus': True},服务器返回的数据为:{"token":"eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsInRlbmFudElkIjoiLTEiLCJleHAiOjE2OTk0OTk1ODcsImlhdCI6MTY5OTQxMzE4N30.GdRH42ljeWzswrogstkypbNAw8eyH6UXwBUTTCyno5a-WoavV0pYely6MP54KOUWg4NYh5dkEbSAUQdR4Osd3g","username":"超级管理员","account":"admin","userId":"1","expiration":86400,"loginStatus":true,"userAttrs":{"tenantId":"-1"}} - 黄总
2023-11-08 11:13:08,784 - test_bpm_laohuang.py[line:63] - ERROR: 断言失败,用例数据为:None,期望数据为:{'message': '刷新成功'},服务器返回的数据为:{"token":"eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsInRlbmFudElkIjoiLTEiLCJleHAiOjE2OTk0OTk1ODgsImlhdCI6MTY5OTQxMzE4OH0.vntB1YTqCCD7KKpavnYtzTcv8Xzho2rHtlLp5m84TE00qU6XcS1tJA5HiCvxQGCTxY0xdcrWSVPI3r_CJVv-MQ","username":"","account":"","userId":"","loginStatus":true,"userAttrs":{}} - 黄总
2023-11-08 11:13:09,377 - test_bpm_laohuang.py[line:63] - ERROR: 断言失败,用例数据为:{'ids': '1722089844974305280'},期望数据为:{'state': True, 'message': '删除维度成功'},服务器返回的数据为:{"state":true,"message":"删除维度成功!","value":""} - 黄总
2023-11-08 11:13:09,993 - test_bpm.py[line:59] - ERROR: 断言失败,用例数据为:{'password': 'MTIzNDU2', 'username': 'admin'},期望数据为:{'username': '超级管理', 'account': 'admin', 'loginStatus': True},服务器返回的数据为:{"token":"eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsInRlbmFudElkIjoiLTEiLCJleHAiOjE2OTk0OTk1ODksImlhdCI6MTY5OTQxMzE4OX0.NZhdCeufTnxONEUamhmB58XkQ6CzYFf6Y6Kjo0txlAxvpahRSmD5Upg0PDOzSL-7e-YU99gYuBK4DNBmN73jEA","username":"超级管理员","account":"admin","userId":"1","expiration":86400,"loginStatus":true,"userAttrs":{"tenantId":"-1"}} - 黄总
2023-11-08 11:13:10,946 - test_bpm.py[line:59] - ERROR: 断言失败,用例数据为:None,期望数据为:{'message': '刷新成功'},服务器返回的数据为:{"token":"eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsInRlbmFudElkIjoiLTEiLCJleHAiOjE2OTk0OTk1OTAsImlhdCI6MTY5OTQxMzE5MH0.4BXKDRrF59dxXunFKL6tXEN4acZ-yUs7OnfxUWQA2UDtU2EnGY30IadC4LFWj02-eeyoR4CFzrUTJOjbR8yHnw","username":"","account":"","userId":"","loginStatus":true,"userAttrs":{}} - 黄总
2023-11-08 11:13:11,544 - test_bpm.py[line:59] - ERROR: 断言失败,用例数据为:{'ids': '1722089854029807616'},期望数据为:{'state': True, 'message': '删除维度成功'},服务器返回的数据为:{"state":true,"message":"删除维度成功!","value":""} - 黄总
2023-11-08 16:53:06,374 - test_bpm_laohuang.py[line:63] - ERROR: 断言失败,用例数据为:{'password': 'MTIzNDU2', 'username': 'admin'},期望数据为:{'username': '超级管理', 'account': 'admin', 'loginStatus': True},服务器返回的数据为:{"token":"eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsInRlbmFudElkIjoiLTEiLCJleHAiOjE2OTk1MTk5ODUsImlhdCI6MTY5OTQzMzU4NX0.xXclL_RMtmmfqV2BM7X85-J9ku_QYVDjhNElF3vP-8KDvIBCiIv9B5gBKnOvTfyn3tN5t2zP4zgadb5FqT-ZYg","username":"超级管理员","account":"admin","userId":"1","expiration":86400,"loginStatus":true,"userAttrs":{"tenantId":"-1"}} - 黄总
2023-11-08 16:53:07,467 - test_bpm_laohuang.py[line:63] - ERROR: 断言失败,用例数据为:None,期望数据为:{'message': '刷新成功'},服务器返回的数据为:{"token":"eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsInRlbmFudElkIjoiLTEiLCJleHAiOjE2OTk1MTk5ODYsImlhdCI6MTY5OTQzMzU4Nn0.Sh-K1__3ExZH4bNbfm7yIi04LIYwT-cPi2p5LEunQNJHfjlDsL0VQ60Nm0QayAxiK17gVWHGEfaSWD_KwDGIpQ","username":"","account":"","userId":"","loginStatus":true,"userAttrs":{}} - 黄总
2023-11-08 16:53:08,073 - test_bpm_laohuang.py[line:63] - ERROR: 断言失败,用例数据为:{'ids': '1722175401779806208'},期望数据为:{'state': True, 'message': '删除维度成功'},服务器返回的数据为:{"state":true,"message":"删除维度成功!","value":""} - 黄总
2023-11-08 16:54:17,961 - test_bpm.py[line:63] - ERROR: 断言失败,用例数据为:{'password': 'MTIzNDU2', 'username': 'admin'},期望数据为:{'username': '超级管理', 'account': 'admin', 'loginStatus': True},服务器返回的数据为:{"token":"eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsInRlbmFudElkIjoiLTEiLCJleHAiOjE2OTk1MjAwNTcsImlhdCI6MTY5OTQzMzY1N30.4iKRXyUrAspPgmfXoZro9Wjx1VujBuJiXHoqK-yBXg95CV_2a9hQ9rFHFufq-Nh48Rwz5u1ErGC31hIXk8G28w","username":"超级管理员","account":"admin","userId":"1","expiration":86400,"loginStatus":true,"userAttrs":{"tenantId":"-1"}} - 黄总
2023-11-08 16:54:19,095 - test_bpm.py[line:63] - ERROR: 断言失败,用例数据为:None,期望数据为:{'message': '刷新成功'},服务器返回的数据为:{"token":"eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsInRlbmFudElkIjoiLTEiLCJleHAiOjE2OTk1MjAwNTgsImlhdCI6MTY5OTQzMzY1OH0.LnvdXb8XPiMm7TqCwmkvzfyq4tLA9D1SwL_i8sXHTzBzFcXmUqgYqsc6cDxD6nnMgiNscqe-m6b9-5jkLqzLSA","username":"","account":"","userId":"","loginStatus":true,"userAttrs":{}} - 黄总
2023-11-08 16:54:19,688 - test_bpm.py[line:63] - ERROR: 断言失败,用例数据为:{'ids': '1722175702201024512'},期望数据为:{'state': True, 'message': '删除维度成功'},服务器返回的数据为:{"state":true,"message":"删除维度成功!","value":""} - 黄总
2023-11-08 16:56:30,131 - test_bpm_laohuang.py[line:63] - ERROR: 断言失败,用例数据为:{'password': 'MTIzNDU2', 'username': 'admin'},期望数据为:{'username': '超级管理', 'account': 'admin', 'loginStatus': True},服务器返回的数据为:{"token":"eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsInRlbmFudElkIjoiLTEiLCJleHAiOjE2OTk1MjAxODksImlhdCI6MTY5OTQzMzc4OX0.LkJ7N94OH61pJ8kl1O0enf4yXr1GRjg79DDbj_SAeQS9EpZWduMCjxi54KAZFr2AtgF3r7nWF_0Yy4xgkWNqoA","username":"超级管理员","account":"admin","userId":"1","expiration":86400,"loginStatus":true,"userAttrs":{"tenantId":"-1"}} - 黄总
2023-11-08 16:56:31,242 - test_bpm_laohuang.py[line:63] - ERROR: 断言失败,用例数据为:None,期望数据为:{'message': '刷新成功'},服务器返回的数据为:{"token":"eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsInRlbmFudElkIjoiLTEiLCJleHAiOjE2OTk1MjAxOTAsImlhdCI6MTY5OTQzMzc5MH0.D6HrSQGl8pkb_0wTF9QiRXG990nZA5m4IqklrcK-2IiB2-cEti2hd_K4pORlm2F9PDKaeRvnzW6DwOgMMt0iNw","username":"","account":"","userId":"","loginStatus":true,"userAttrs":{}} - 黄总
2023-11-08 16:56:31,849 - test_bpm_laohuang.py[line:63] - ERROR: 断言失败,用例数据为:{'ids': '1722176256495075328'},期望数据为:{'state': True, 'message': '删除维度成功'},服务器返回的数据为:{"state":true,"message":"删除维度成功!","value":""} - 黄总
2023-11-08 16:57:13,610 - test_bpm.py[line:63] - ERROR: 断言失败,用例数据为:{'password': 'MTIzNDU2', 'username': 'admin'},期望数据为:{'username': '超级管理', 'account': 'admin', 'loginStatus': True},服务器返回的数据为:{"token":"eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsInRlbmFudElkIjoiLTEiLCJleHAiOjE2OTk1MjAyMzIsImlhdCI6MTY5OTQzMzgzMn0.GUTwqREC-1F_TzhsT3pnZ7W1fzvY8EIEQcJ1--RSf4ZZlaQtZUgjz5c8xGS5fBY7lNQHNzg0i__6V_GImeYbHA","username":"超级管理员","account":"admin","userId":"1","expiration":86400,"loginStatus":true,"userAttrs":{"tenantId":"-1"}} - 黄总
2023-11-08 16:57:14,743 - test_bpm.py[line:63] - ERROR: 断言失败,用例数据为:None,期望数据为:{'message': '刷新成功'},服务器返回的数据为:{"token":"eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsInRlbmFudElkIjoiLTEiLCJleHAiOjE2OTk1MjAyMzQsImlhdCI6MTY5OTQzMzgzNH0.ouZh8M6U6-T8ChF64ly8zy4TXUp3CUwDTjHPjNYVppyITNbvC-uoKSD0aK1dGkS28GycZKjycZmsHioeWxMN3Q","username":"","account":"","userId":"","loginStatus":true,"userAttrs":{}} - 黄总
2023-11-08 16:57:15,342 - test_bpm.py[line:63] - ERROR: 断言失败,用例数据为:{'ids': '1722176438934716416'},期望数据为:{'state': True, 'message': '删除维度成功'},服务器返回的数据为:{"state":true,"message":"删除维度成功!","value":""} - 黄总
2023-11-08 17:04:14,183 - test_bpm_laohuang.py[line:63] - ERROR: 断言失败,用例数据为:{'password': 'MTIzNDU2', 'username': 'admin'},期望数据为:{'username': '超级管理', 'account': 'admin', 'loginStatus': True},服务器返回的数据为:{"token":"eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsInRlbmFudElkIjoiLTEiLCJleHAiOjE2OTk1MjA2NTMsImlhdCI6MTY5OTQzNDI1M30.DPDRU9DySIgqpY017l7rqzvhXqb85sRri3cuGZ8cBxywUHh9ojVh-meAHT_T-So-cVKj5khdPriSGirX6Jptfg","username":"超级管理员","account":"admin","userId":"1","expiration":86400,"loginStatus":true,"userAttrs":{"tenantId":"-1"}} - 黄总
2023-11-08 17:04:14,183 - test_bpm_laohuang.py[line:63] - ERROR: 断言失败,用例数据为:{'password': 'MTIzNDU2', 'username': 'admin'},期望数据为:{'username': '超级管理', 'account': 'admin', 'loginStatus': True},服务器返回的数据为:{"token":"eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsInRlbmFudElkIjoiLTEiLCJleHAiOjE2OTk1MjA2NTMsImlhdCI6MTY5OTQzNDI1M30.DPDRU9DySIgqpY017l7rqzvhXqb85sRri3cuGZ8cBxywUHh9ojVh-meAHT_T-So-cVKj5khdPriSGirX6Jptfg","username":"超级管理员","account":"admin","userId":"1","expiration":86400,"loginStatus":true,"userAttrs":{"tenantId":"-1"}} - 黄总
2023-11-08 17:04:15,288 - test_bpm_laohuang.py[line:63] - ERROR: 断言失败,用例数据为:None,期望数据为:{'message': '刷新成功'},服务器返回的数据为:{"token":"eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsInRlbmFudElkIjoiLTEiLCJleHAiOjE2OTk1MjA2NTQsImlhdCI6MTY5OTQzNDI1NH0.NIM4dW0OjoqThvo_poQ2ESsuGq1DYIFLhOQXZZ3Y8Psx9QzZPCextw6JebcR8y5eG0BJcaJLngTZtRUD8z8dXA","username":"","account":"","userId":"","loginStatus":true,"userAttrs":{}} - 黄总
2023-11-08 17:04:16,042 - test_bpm_laohuang.py[line:63] - ERROR: 断言失败,用例数据为:{'ids': '1722178202807320576'},期望数据为:{'state': True, 'message': '删除维度成功'},服务器返回的数据为:{"state":true,"message":"删除维度成功!","value":""} - 黄总
2023-11-08 17:04:16,372 - test_bpm.py[line:63] - ERROR: 断言失败,用例数据为:{'password': 'MTIzNDU2', 'username': 'admin'},期望数据为:{'username': '超级管理', 'account': 'admin', 'loginStatus': True},服务器返回的数据为:{"token":"eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsInRlbmFudElkIjoiLTEiLCJleHAiOjE2OTk1MjA2NTUsImlhdCI6MTY5OTQzNDI1NX0.59p7k7YBCf6MFV010I5E_Ur6AhLBGQWFCqtplSrnXN7l3Ge8DqXPSfTOOR_yFu5lCT4nTXo7byaOHVchzJN6TQ","username":"超级管理员","account":"admin","userId":"1","expiration":86400,"loginStatus":true,"userAttrs":{"tenantId":"-1"}} - 黄总
2023-11-08 17:04:17,307 - test_bpm.py[line:63] - ERROR: 断言失败,用例数据为:None,期望数据为:{'message': '刷新成功'},服务器返回的数据为:{"token":"eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsInRlbmFudElkIjoiLTEiLCJleHAiOjE2OTk1MjA2NTYsImlhdCI6MTY5OTQzNDI1Nn0.joPTowcJfAB2Cadxzb8_lqQgMBGSkfYmKfzjcUYbesboSoRIleejTQDv2V1_6SFJ4LC5wKCmLv6pCebOWQBgQA","username":"","account":"","userId":"","loginStatus":true,"userAttrs":{}} - 黄总
2023-11-08 17:04:17,936 - test_bpm.py[line:63] - ERROR: 断言失败,用例数据为:{'ids': '1722178211275620352'},期望数据为:{'state': True, 'message': '删除维度成功'},服务器返回的数据为:{"state":true,"message":"删除维度成功!","value":""} - 黄总
2023-11-08 17:04:18,458 - test_bpm.py[line:63] - ERROR: 断言失败,用例数据为:{'password': 'MTIzNDU2', 'username': 'admin'},期望数据为:{'username': '超级管理', 'account': 'admin', 'loginStatus': True},服务器返回的数据为:{"token":"eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsInRlbmFudElkIjoiLTEiLCJleHAiOjE2OTk1MjA2NTcsImlhdCI6MTY5OTQzNDI1N30.JLSYAOQMmtqgPanvBJCppdXo84p0uFU_O_q2PBa0Vk8JAohkeLCdj936_uA2ciVTVdDA_N3BqAB9KLwz8ayuJA","username":"超级管理员","account":"admin","userId":"1","expiration":86400,"loginStatus":true,"userAttrs":{"tenantId":"-1"}} - 黄总
2023-11-08 17:04:19,401 - test_bpm.py[line:63] - ERROR: 断言失败,用例数据为:None,期望数据为:{'message': '刷新成功'},服务器返回的数据为:{"token":"eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsInRlbmFudElkIjoiLTEiLCJleHAiOjE2OTk1MjA2NTgsImlhdCI6MTY5OTQzNDI1OH0.7BFLRDdjZ-Le_g_cQsXg9GNZcg99TjCco1CBqGq8VqLU47zPg_wUqkLnDI7XacvKkkdXRr0n2QhulbLjVTlC7g","username":"","account":"","userId":"","loginStatus":true,"userAttrs":{}} - 黄总
2023-11-08 17:04:20,019 - test_bpm.py[line:63] - ERROR: 断言失败,用例数据为:{'ids': '1722178220062687232'},期望数据为:{'state': True, 'message': '删除维度成功'},服务器返回的数据为:{"state":true,"message":"删除维度成功!","value":""} - 黄总
......@@ -8,13 +8,10 @@
#
# ---------------------------------------------------------------------------
import base64
import logging
import requests
from InterfaceAutoTest.common import log
from InterfaceAutoTest.common.read_ini import ReadIni
from InterfaceAutoTest.data_config.settings import *
from InterfaceAutoTest_v3.common import log
from InterfaceAutoTest_v3.common.read_ini import ReadIni
from InterfaceAutoTest_v3.data_config.settings import *
class RequestsMethod:
......
......@@ -7,6 +7,3 @@
# Description:
#
# ---------------------------------------------------------------------------
# 增加的注释信息,用于测试轮询SCM模式
......@@ -8,8 +8,8 @@
#
# ---------------------------------------------------------------------------
import pytest
from InterfaceAutoTest.common.db import DB
from InterfaceAutoTest.requests_method.requests_method import RequestsMethod
from InterfaceAutoTest_v3.common.db import DB
from InterfaceAutoTest_v3.requests_method.requests_method import RequestsMethod
@pytest.fixture(scope="session")
......@@ -29,9 +29,8 @@ def db_fix():
# <====================================================end
def pytest_collection_modifyitems(items):
# item表示每个测试用例,解决用例名称中文显示问题
for item in items:
item.name = item.name.encode("utf-8").decode("unicode-escape")
item._nodeid = item._nodeid.encode("utf-8").decode("unicode-escape")
\ No newline at end of file
item._nodeid = item._nodeid.encode("utf-8").decode("unicode-escape")
2023-11-08 16:56:30 - test_bpm_laohuang.py[line:63] - ERROR: 断言失败,用例数据为:{'password': 'MTIzNDU2', 'username': 'admin'},期望数据为:{'username': '超级管理', 'account': 'admin', 'loginStatus': True},服务器返回的数据为:{"token":"eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsInRlbmFudElkIjoiLTEiLCJleHAiOjE2OTk1MjAxODksImlhdCI6MTY5OTQzMzc4OX0.LkJ7N94OH61pJ8kl1O0enf4yXr1GRjg79DDbj_SAeQS9EpZWduMCjxi54KAZFr2AtgF3r7nWF_0Yy4xgkWNqoA","username":"超级管理员","account":"admin","userId":"1","expiration":86400,"loginStatus":true,"userAttrs":{"tenantId":"-1"}}
2023-11-08 16:56:30 - test_bpm_laohuang.py[line:63] - ERROR: 断言失败,用例数据为:{'password': 'MTIzNDU2', 'username': 'admin'},期望数据为:{'username': '超级管理', 'account': 'admin', 'loginStatus': True},服务器返回的数据为:{"token":"eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsInRlbmFudElkIjoiLTEiLCJleHAiOjE2OTk1MjAxODksImlhdCI6MTY5OTQzMzc4OX0.LkJ7N94OH61pJ8kl1O0enf4yXr1GRjg79DDbj_SAeQS9EpZWduMCjxi54KAZFr2AtgF3r7nWF_0Yy4xgkWNqoA","username":"超级管理员","account":"admin","userId":"1","expiration":86400,"loginStatus":true,"userAttrs":{"tenantId":"-1"}}
2023-11-08 16:56:31 - test_bpm_laohuang.py[line:63] - ERROR: 断言失败,用例数据为:None,期望数据为:{'message': '刷新成功'},服务器返回的数据为:{"token":"eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsInRlbmFudElkIjoiLTEiLCJleHAiOjE2OTk1MjAxOTAsImlhdCI6MTY5OTQzMzc5MH0.D6HrSQGl8pkb_0wTF9QiRXG990nZA5m4IqklrcK-2IiB2-cEti2hd_K4pORlm2F9PDKaeRvnzW6DwOgMMt0iNw","username":"","account":"","userId":"","loginStatus":true,"userAttrs":{}}
2023-11-08 16:56:31 - test_bpm_laohuang.py[line:63] - ERROR: 断言失败,用例数据为:{'ids': '1722176256495075328'},期望数据为:{'state': True, 'message': '删除维度成功'},服务器返回的数据为:{"state":true,"message":"删除维度成功!","value":""}
......@@ -8,8 +8,8 @@
#
# ---------------------------------------------------------------------------
import pytest
from InterfaceAutoTest.common import log
from InterfaceAutoTest.common.read_excel import ReadExcel
from InterfaceAutoTest_v3.common import log
from InterfaceAutoTest_v3.common.read_excel import ReadExcel
import allure
......@@ -21,7 +21,7 @@ class TestBPM:
# @allure.title("用例标题")
# @allure.severity("用例等级")
@pytest.mark.parametrize("module_name, api_name, title, level, case_url, case_method, case_mime, case_data, "
"expect_data, sql_type, sql_data, update_key", ReadExcel("BPM-laohuang").get_data())
"expect_data, sql_type, sql_data, update_key", ReadExcel("BPM-laohuang", "laohuang/APIAutoTest.xlsx", "laohuang/case_data.json", "laohuang/expect_data.json", "laohuang/sql_data.json").get_data())
def test_bpm(self, db_fix, req_fix, module_name, api_name, title, level, case_url, case_method, case_mime,
case_data, expect_data, sql_type, sql_data, update_key):
# 影响allure报告的数据,不影响代码流程
......
......@@ -8,8 +8,8 @@
#
# ---------------------------------------------------------------------------
import pytest
from InterfaceAutoTest.common.db import DB
from InterfaceAutoTest.requests_method.requests_method import RequestsMethod
from InterfaceAutoTest_v3.common.db import DB
from InterfaceAutoTest_v3.requests_method.requests_method import RequestsMethod
@pytest.fixture(scope="session")
......@@ -29,8 +29,9 @@ def db_fix():
# <====================================================end
# def pytest_collection_modifyitems(items):
# # item表示每个测试用例,解决用例名称中文显示问题
# for item in items:
# item.name = item.name.encode("utf-8").decode("unicode-escape")
# item._nodeid = item._nodeid.encode("utf-8").decode("unicode-escape")
def pytest_collection_modifyitems(items):
# item表示每个测试用例,解决用例名称中文显示问题
for item in items:
item.name = item.name.encode("utf-8").decode("unicode-escape")
item._nodeid = item._nodeid.encode("utf-8").decode("unicode-escape")
\ No newline at end of file
[pytest]
;开启日志
;log_cli=true
;设置日志的级别,如果不设置级别的话,可以设置为NOTSET,如果要设置级别,级别可以有debug,info,warning,error,致命
;log_level=NOTSET
;设置日志显示的信息格式
;log_format=%(asctime)s - %(filename)s[line:%(lineno)d] - %(levelname)s: %(message)s
;设置日志中时间显示的格式
;log_date_format=%Y-%m-%d %H:%M:%S
;每个py文件运行的时候追加的命令
;addopts=-vs
;设置日志保存的文件
log_file=./report/log/bpm_接口自动化框架最新运行日志.log
;设置日志保存在文件中的级别
log_file_level=error
;设置日志在文件中的信息格式
log_file_format=%(asctime)s - %(filename)s[line:%(lineno)d] - %(levelname)s: %(message)s
;设置文件日志中时间显示的格式
log_file_date_format=%Y-%m-%d %H:%M:%S
\ No newline at end of file
2023-11-08 16:57:13 - test_bpm.py[line:63] - ERROR: 断言失败,用例数据为:{'password': 'MTIzNDU2', 'username': 'admin'},期望数据为:{'username': '超级管理', 'account': 'admin', 'loginStatus': True},服务器返回的数据为:{"token":"eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsInRlbmFudElkIjoiLTEiLCJleHAiOjE2OTk1MjAyMzIsImlhdCI6MTY5OTQzMzgzMn0.GUTwqREC-1F_TzhsT3pnZ7W1fzvY8EIEQcJ1--RSf4ZZlaQtZUgjz5c8xGS5fBY7lNQHNzg0i__6V_GImeYbHA","username":"超级管理员","account":"admin","userId":"1","expiration":86400,"loginStatus":true,"userAttrs":{"tenantId":"-1"}}
2023-11-08 16:57:13 - test_bpm.py[line:63] - ERROR: 断言失败,用例数据为:{'password': 'MTIzNDU2', 'username': 'admin'},期望数据为:{'username': '超级管理', 'account': 'admin', 'loginStatus': True},服务器返回的数据为:{"token":"eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsInRlbmFudElkIjoiLTEiLCJleHAiOjE2OTk1MjAyMzIsImlhdCI6MTY5OTQzMzgzMn0.GUTwqREC-1F_TzhsT3pnZ7W1fzvY8EIEQcJ1--RSf4ZZlaQtZUgjz5c8xGS5fBY7lNQHNzg0i__6V_GImeYbHA","username":"超级管理员","account":"admin","userId":"1","expiration":86400,"loginStatus":true,"userAttrs":{"tenantId":"-1"}}
2023-11-08 16:57:14 - test_bpm.py[line:63] - ERROR: 断言失败,用例数据为:None,期望数据为:{'message': '刷新成功'},服务器返回的数据为:{"token":"eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsInRlbmFudElkIjoiLTEiLCJleHAiOjE2OTk1MjAyMzQsImlhdCI6MTY5OTQzMzgzNH0.ouZh8M6U6-T8ChF64ly8zy4TXUp3CUwDTjHPjNYVppyITNbvC-uoKSD0aK1dGkS28GycZKjycZmsHioeWxMN3Q","username":"","account":"","userId":"","loginStatus":true,"userAttrs":{}}
2023-11-08 16:57:15 - test_bpm.py[line:63] - ERROR: 断言失败,用例数据为:{'ids': '1722176438934716416'},期望数据为:{'state': True, 'message': '删除维度成功'},服务器返回的数据为:{"state":true,"message":"删除维度成功!","value":""}
......@@ -8,23 +8,28 @@
#
# ---------------------------------------------------------------------------
import pytest
from InterfaceAutoTest.common import log
from InterfaceAutoTest.common.read_excel import ReadExcel
from InterfaceAutoTest.common.read_ini import ReadIni
from InterfaceAutoTest_v3.common import log
from InterfaceAutoTest_v3.common.read_excel import ReadExcel
import allure
excel_path = ReadIni().get_file_path("excel")
class TestBPM:
@allure.epic("BPM_张三")
@pytest.mark.parametrize("module_name, api_name, title, level, case_url, case_method, case_mime, case_data, expect_data, sql_type, sql_data, update_key", ReadExcel("BPM", excel_path=excel_path).get_data())
def test_bpm(self, db_fix, req_fix, module_name, api_name, title, level, case_url, case_method, case_mime, case_data, expect_data, sql_type, sql_data, update_key):
@allure.epic("BPM项目-老黄")
# @allure.feature("模块名称")
# @allure.story("接口名称")
# @allure.title("用例标题")
# @allure.severity("用例等级")
@pytest.mark.parametrize("module_name, api_name, title, level, case_url, case_method, case_mime, case_data, "
"expect_data, sql_type, sql_data, update_key", ReadExcel("BPM-lisi", "lisi/APIAutoTest.xlsx", "lisi/case_data.json", "lisi/expect_data.json", "lisi/sql_data.json").get_data())
def test_bpm(self, db_fix, req_fix, module_name, api_name, title, level, case_url, case_method, case_mime,
case_data, expect_data, sql_type, sql_data, update_key):
# 影响allure报告的数据,不影响代码流程
allure.dynamic.feature(module_name)
allure.dynamic.story(api_name)
allure.dynamic.title(title)
allure.dynamic.severity(level)
# 判断sql语句的类型是否为delete
if sql_type == "delete":
# 使用DB类对象执行删除的sql语句
......@@ -50,7 +55,6 @@ class TestBPM:
# 使用RequestsMethod类对象发送请求
res = req_fix.request_all(req_method=case_method, req_url=case_url, req_mime=case_mime, case_data=case_data)
# 断言
try:
for key in expect_data:
......
[pytest]
;开启日志
;log_cli=true
;设置日志的级别,如果不设置级别的话,可以设置为NOTSET,如果要设置级别,级别可以有debug,info,warning,error,致命
;log_level=NOTSET
;设置日志显示的信息格式
;log_format=%(asctime)s - %(filename)s[line:%(lineno)d] - %(levelname)s: %(message)s
;设置日志中时间显示的格式
;log_date_format=%Y-%m-%d %H:%M:%S
;每个py文件运行的时候追加的命令
;addopts=-vs
;设置日志保存的文件
log_file=./report/log/bpm_接口自动化框架最新运行日志.log
;设置日志保存在文件中的级别
log_file_level=error
;设置日志在文件中的信息格式
log_file_format=%(asctime)s - %(filename)s[line:%(lineno)d] - %(levelname)s: %(message)s
;设置文件日志中时间显示的格式
log_file_date_format=%Y-%m-%d %H:%M:%S
\ No newline at end of file
++ "b/InterfaceAutoTest_v3/test_case/test_order/report/log/bpm_\346\216\245\345\217\243\350\207\252\345\212\250\345\214\226\346\241\206\346\236\266\346\234\200\346\226\260\350\277\220\350\241\214\346\227\245\345\277\227.log"
......@@ -72,7 +72,7 @@ class Test01:
print("添加维度用例")
add_dem_url = "http://120.46.172.186:8080/api/demension/v1/dem/addDem"
add_dem_data = {
"code": "addDem"+str(random.randrange(1, 100)),
"code": "addDem"+str(random.randrange(100, 999)),
"description": "addDem",
"isDefault": 0,
"name": "addDem"
......@@ -82,7 +82,7 @@ class Test01:
print(res.text)
assert "添加维度成功" in res.text
@pytest.mark.dependency(depends=["test1", "test2"])
@pytest.mark.dependency(depends=["Test01::test1", "Test01::test2"])
def test3(self):
print("用例3")
......
# -*-coding:utf-8 -*- #
# ---------------------------------------------------------------------------
# ProjectName: test_57
# FileName: __init__.py
# Author: xxxxxxx
# Datetime: 2023/11/3 17:38
# Description:
#
# ---------------------------------------------------------------------------
# -*-coding:utf-8 -*- #
# ---------------------------------------------------------------------------
# ProjectName: test_57
# FileName: conftest.py
# Author: xxxxxxx
# Datetime: 2023/11/3 15:33
# Description:
#
# ---------------------------------------------------------------------------
import pytest
from InterfaceAutoTest_v3.common.db import DB
from InterfaceAutoTest_v3.requests_method.requests_method import RequestsMethod
@pytest.fixture(scope="session")
def req_fix():
req = RequestsMethod()
yield req
@pytest.fixture(scope="session")
def db_fix():
db = DB()
yield db
db.close()
# 黄总定义的自定义固件,请勿乱动=================start=========>
# <====================================================end
def pytest_collection_modifyitems(items):
# item表示每个测试用例,解决用例名称中文显示问题
for item in items:
item.name = item.name.encode("utf-8").decode("unicode-escape")
item._nodeid = item._nodeid.encode("utf-8").decode("unicode-escape")
\ No newline at end of file
[pytest]
;开启日志
;log_cli=true
;设置日志的级别,如果不设置级别的话,可以设置为NOTSET,如果要设置级别,级别可以有debug,info,warning,error,致命
;log_level=NOTSET
;设置日志显示的信息格式
;log_format=%(asctime)s - %(filename)s[line:%(lineno)d] - %(levelname)s: %(message)s
;设置日志中时间显示的格式
;log_date_format=%Y-%m-%d %H:%M:%S
;每个py文件运行的时候追加的命令
;addopts=-vs
;设置日志保存的文件
log_file=./report/log/bpm_接口自动化框架最新运行日志.log
;设置日志保存在文件中的级别
log_file_level=error
;设置日志在文件中的信息格式
log_file_format=%(asctime)s - %(filename)s[line:%(lineno)d] - %(levelname)s: %(message)s
;设置文件日志中时间显示的格式
log_file_date_format=%Y-%m-%d %H:%M:%S
\ No newline at end of file
2023-11-08 16:57:13 - test_bpm.py[line:63] - ERROR: 断言失败,用例数据为:{'password': 'MTIzNDU2', 'username': 'admin'},期望数据为:{'username': '超级管理', 'account': 'admin', 'loginStatus': True},服务器返回的数据为:{"token":"eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsInRlbmFudElkIjoiLTEiLCJleHAiOjE2OTk1MjAyMzIsImlhdCI6MTY5OTQzMzgzMn0.GUTwqREC-1F_TzhsT3pnZ7W1fzvY8EIEQcJ1--RSf4ZZlaQtZUgjz5c8xGS5fBY7lNQHNzg0i__6V_GImeYbHA","username":"超级管理员","account":"admin","userId":"1","expiration":86400,"loginStatus":true,"userAttrs":{"tenantId":"-1"}}
2023-11-08 16:57:13 - test_bpm.py[line:63] - ERROR: 断言失败,用例数据为:{'password': 'MTIzNDU2', 'username': 'admin'},期望数据为:{'username': '超级管理', 'account': 'admin', 'loginStatus': True},服务器返回的数据为:{"token":"eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsInRlbmFudElkIjoiLTEiLCJleHAiOjE2OTk1MjAyMzIsImlhdCI6MTY5OTQzMzgzMn0.GUTwqREC-1F_TzhsT3pnZ7W1fzvY8EIEQcJ1--RSf4ZZlaQtZUgjz5c8xGS5fBY7lNQHNzg0i__6V_GImeYbHA","username":"超级管理员","account":"admin","userId":"1","expiration":86400,"loginStatus":true,"userAttrs":{"tenantId":"-1"}}
2023-11-08 16:57:14 - test_bpm.py[line:63] - ERROR: 断言失败,用例数据为:None,期望数据为:{'message': '刷新成功'},服务器返回的数据为:{"token":"eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsInRlbmFudElkIjoiLTEiLCJleHAiOjE2OTk1MjAyMzQsImlhdCI6MTY5OTQzMzgzNH0.ouZh8M6U6-T8ChF64ly8zy4TXUp3CUwDTjHPjNYVppyITNbvC-uoKSD0aK1dGkS28GycZKjycZmsHioeWxMN3Q","username":"","account":"","userId":"","loginStatus":true,"userAttrs":{}}
2023-11-08 16:57:15 - test_bpm.py[line:63] - ERROR: 断言失败,用例数据为:{'ids': '1722176438934716416'},期望数据为:{'state': True, 'message': '删除维度成功'},服务器返回的数据为:{"state":true,"message":"删除维度成功!","value":""}
# -*-coding:utf-8 -*- #
# ---------------------------------------------------------------------------
# ProjectName: test_57
# FileName: test_bpm.py
# Author: xxxxxxx
# Datetime: 2023/11/3 15:33
# Description:
#
# ---------------------------------------------------------------------------
import pytest
from InterfaceAutoTest_v3.common import log
from InterfaceAutoTest_v3.common.read_excel import ReadExcel
import allure
class TestBPM:
@allure.epic("BPM项目-老黄")
# @allure.feature("模块名称")
# @allure.story("接口名称")
# @allure.title("用例标题")
# @allure.severity("用例等级")
@pytest.mark.parametrize("module_name, api_name, title, level, case_url, case_method, case_mime, case_data, "
"expect_data, sql_type, sql_data, update_key", ReadExcel("BPM", "zhangsan/APIAutoTest.xlsx", "zhangsan/case_data.json", "zhangsan/expect_data.json", "zhangsan/sql_data.json").get_data())
def test_bpm(self, db_fix, req_fix, module_name, api_name, title, level, case_url, case_method, case_mime,
case_data, expect_data, sql_type, sql_data, update_key):
# 影响allure报告的数据,不影响代码流程
allure.dynamic.feature(module_name)
allure.dynamic.story(api_name)
allure.dynamic.title(title)
allure.dynamic.severity(level)
# 判断sql语句的类型是否为delete
if sql_type == "delete":
# 使用DB类对象执行删除的sql语句
db_fix.delete(sql_data)
# 使用RequestsMethod类对象发送请求--pass
# 判断sql语句类型是否为select
elif sql_type == "select":
# 使用DB类对象执行查询的sql语句,并接收查询的结果
select_result = db_fix.select(sql_data)
# 将查询结果更新到用例数据中
case_data[update_key] = select_result
# 使用RequestsMethod类对象发送请求--pass
# 判断sql语句的类型是否为select|delete或者为delete|select
elif sql_type == "select|delete" or sql_type == "delete|select":
# 使用DB类对象执行删除的sql语句
db_fix.delete(sql_data.get("delete"))
# 使用DB类对象执行查询的sql语句,并接收查询的结果
select_result = db_fix.select(sql_data.get("select"))
# 将查询结果更新到用例数据中
case_data[update_key] = select_result
# 使用RequestsMethod类对象发送请求
res = req_fix.request_all(req_method=case_method, req_url=case_url, req_mime=case_mime, case_data=case_data)
# 断言
try:
for key in expect_data:
assert expect_data[key] == res.json().get(key)
except:
log.error("断言失败"+",用例数据为:"+str(case_data)+",期望数据为:"+str(expect_data)+",服务器返回的数据为:"+res.text)
raise AssertionError("断言失败")
if __name__ == '__main__':
pytest.main()
\ 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