Arthur-Wu committed this file on 2024-11-15

This commit is contained in:
ieemoo
2024-11-15 17:35:57 +08:00
parent c871e12b16
commit 298268c133
20 changed files with 595 additions and 18 deletions

View File

@ -13,15 +13,16 @@ class Engine():
self.CasesSuite = []
self.rootpath = os.path.dirname(os.path.dirname(__file__))
self.FolderPath = ReturnFolder
self.projectCasesPath = str(os.path.join(GlobalPath['YMCaseScriptsPath']).replace("\\", "/"))
self.TestSuiteName = str(os.path.join(GlobalPath[ProCfgData["ExecutionScope"]]).replace("\\", "/"))
self.ReportName = "Reports"
self.newName = "亿猫业务场景接口自动化测试报告"
def __execute(self):
'''@Author:: Arthur Wu
@Date:: 2024/5/9
:return:
'''
for dirpath, dirnames, filenames in os.walk(self.projectCasesPath):
for dirpath, dirnames, filenames in os.walk(self.TestSuiteName):
for fn in filenames:
if fn.startswith("test_"):
caseScriptPath = os.path.join(dirpath, fn).replace("\\", "/")
@ -35,7 +36,9 @@ class Engine():
+ ' --workers=2 '+'--tests-per-worker=2',
shell=True,
stdout=subprocess.PIPE).stdout.read()
folder_path = os.path.join(self.FolderPath, 'html').replace('\\', '/')
LOGGER.info("---[INFO] Allure html report generate complete !")
return folder_path
def __move_file(self):
rootpath = (os.getcwd()).replace("\\", "/")
@ -65,14 +68,24 @@ class Engine():
os.remove(file_path)
print(f"已删除: {file_path}")
def __set_overview_title(self, index_path, new_name):
title_filepath = os.path.join(index_path, "widgets", "summary.json")
with open(title_filepath, 'rb') as f:
params = json.load(f)
params['reportName'] = new_name
new_params = params
with open(title_filepath, 'w', encoding="utf-8") as f:
json.dump(new_params, f, ensure_ascii=False, indent=4)
def run_test_suite(self):
txtPath = os.path.join(self.rootpath, "YiMao/ProcessData")
self.__delete_pycache_dirs(self.rootpath)
self.__delete_txt_files(txtPath)
self.__execute()
indexh5path = self.__execute()
self.__set_overview_title(indexh5path, self.newName)
returnList = []
lastReportPath = self.__move_file()
returnList.append(lastReportPath)
# lastReportPath = self.__move_file()
# returnList.append(lastReportPath)
self.__delete_txt_files(txtPath)
self.__delete_pycache_dirs(self.rootpath)
return returnList
@ -84,8 +97,8 @@ class NotificationModule():
"Debug": "7aedbee7239870e3e653748a2889d8bf063c61efa9213c7099bd57476066dc86",
"Formal": "80b026022a28166cfc9eebaf8f6a880cc06f56a14b8803e8d67e7fb3cb05844e"
}
# self.urlInfo = f'https://oapi.dingtalk.com/robot/send?access_token={datainfo["Debug"]}'
self.urlInfo = f'https://oapi.dingtalk.com/robot/send?access_token={datainfo["Formal"]}'
self.urlInfo = f'https://oapi.dingtalk.com/robot/send?access_token={datainfo["Debug"]}'
# self.urlInfo = f'https://oapi.dingtalk.com/robot/send?access_token={datainfo["Formal"]}'
self.ReportUrl = ProCfgData["ReportsURL"]
self.ExecutionEnvironment = ProCfgData["ExecutionEnv"]

View File

@ -4,7 +4,6 @@ from authlib.integrations.requests_client import OAuth2Session
class SignatureYM():
def __init__(self):
self.client_id = "95579765e4fe91af9962"
self.client_secret = "3dcb964ede5d455f1d54623dad5e496bff468f81"
@ -30,3 +29,51 @@ class SignatureYM():
}
return headers
class SignatureYM2():
def __init__(self, Mac= '70:f7:54:07:a6:c0'):
def __sission_id():
import random, time
def generate_24_digit_random_integer():
timestamp = int(time.time() * 1000)
random_number = random.randint(0, 99999999999999)
combined_number = str(timestamp) + str(random_number)
if len(combined_number) >= 24:
return int(combined_number[:24])
else:
combined_number = combined_number.ljust(24, '0')
return int(combined_number)
random_integer = generate_24_digit_random_integer()
return str(random_integer)
self.SessionId = __sission_id()
self.Mac = Mac
def _headers(self):
headers = {
'SessionId': self.SessionId,
'Mac': self.Mac,
'User-Agent': 'Apifox/1.0.0 (https://apifox.com)',
'Content-Type': 'application/json',
'Accept': '*/*',
'Host': 'api.test.yimaogo.com',
'Connection': 'keep-alive',
'App_Version': '6.0.9.107',
'Build_Number': '107',
}
return headers
class SignatureYM3():
def __init__(self, GateMac= '74:ee:2a:df:67:4d'):
self.GateMac = GateMac
def _headers(self):
headers = {
'GateMac': self.GateMac,
'User-Agent': 'Apifox/1.0.0 (https://apifox.com)',
'Content-Type': 'application/json',
'Accept': '*/*',
'Host': 'api.test.yimaogo.com',
'Connection': 'keep-alive'
}
return headers