Commit 7a0b5313 authored by xiao-hesheng's avatar xiao-hesheng
Browse files

优化脚本

parent dc9cd885
...@@ -45,8 +45,14 @@ def test1(orgName='d69a68df361a4289b2262e4ef75b55a5'): ...@@ -45,8 +45,14 @@ def test1(orgName='d69a68df361a4289b2262e4ef75b55a5'):
commonFuc().get_business_data(module, "X-APP-CODE")) commonFuc().get_business_data(module, "X-APP-CODE"))
name = commonFuc().randomString(5) name = commonFuc().randomString(5)
username='自动化测试'+name
info = (username, username)
titlename = ('username1', 'username2')
# 将二级科室id写入文件中
FileUtils().w_info8(info, module, '用户名信息', titlename,"message3")
# # 请求体 # # 请求体
request_body = commonFuc().get_business_data(module, "payload63_9",name,name, orgName,name) request_body = commonFuc().get_business_data(module, "payload63_9",username,username, orgName,username)
print('request_body', request_body) print('request_body', request_body)
# # # # 发送请求 # # # # 发送请求
result = commonFuc().http_post(url, request_body, headers) result = commonFuc().http_post(url, request_body, headers)
......
...@@ -43,10 +43,12 @@ def test1(orgName='d69a68df361a4289b2262e4ef75b55a5'): ...@@ -43,10 +43,12 @@ def test1(orgName='d69a68df361a4289b2262e4ef75b55a5'):
headers = commonFuc().get_business_data(module, "json_headers2", headers = commonFuc().get_business_data(module, "json_headers2",
commonFuc().get_business_data(module, "json_contentType"), token, commonFuc().get_business_data(module, "json_contentType"), token,
commonFuc().get_business_data(module, "X-APP-CODE")) commonFuc().get_business_data(module, "X-APP-CODE"))
#从文件中获取信息
info = FileUtils().r_info6(module, "用户名信息","message3")
print(info)
username1 = info['username1']
# # 请求体 # # 请求体
request_body = commonFuc().get_business_data(module, "payload63_9",username1,username1, orgName,username1)
request_body = commonFuc().get_business_data(module, "payload63_9", orgName)
print('request_body', request_body) print('request_body', request_body)
# # # # 发送请求 # # # # 发送请求
result = commonFuc().http_post(url, request_body, headers) result = commonFuc().http_post(url, request_body, headers)
......
...@@ -43,10 +43,12 @@ def test1(orgName='d69a68df361a4289b2262e4ef75b55a5'): ...@@ -43,10 +43,12 @@ def test1(orgName='d69a68df361a4289b2262e4ef75b55a5'):
headers = commonFuc().get_business_data(module, "json_headers2", headers = commonFuc().get_business_data(module, "json_headers2",
commonFuc().get_business_data(module, "json_contentType"), token, commonFuc().get_business_data(module, "json_contentType"), token,
commonFuc().get_business_data(module, "X-APP-CODE")) commonFuc().get_business_data(module, "X-APP-CODE"))
# 从文件中获取信息
info = FileUtils().r_info6(module, "用户名信息", "message3")
print(info)
username1 = info['username1']
# # 请求体 # # 请求体
request_body = commonFuc().get_business_data(module, "payload63_10", username1,username1, orgName,username1)
request_body = commonFuc().get_business_data(module, "payload63_10", orgName)
print('request_body', request_body) print('request_body', request_body)
# # # # 发送请求 # # # # 发送请求
result = commonFuc().http_post(url, request_body, headers) result = commonFuc().http_post(url, request_body, headers)
......
...@@ -43,9 +43,12 @@ def test1(orgName='d69a68df361a4289b2262e4ef75b55a5'): ...@@ -43,9 +43,12 @@ def test1(orgName='d69a68df361a4289b2262e4ef75b55a5'):
headers = commonFuc().get_business_data(module, "json_headers2", headers = commonFuc().get_business_data(module, "json_headers2",
commonFuc().get_business_data(module, "json_contentType"), token, commonFuc().get_business_data(module, "json_contentType"), token,
commonFuc().get_business_data(module, "X-APP-CODE")) commonFuc().get_business_data(module, "X-APP-CODE"))
# 从文件中获取信息
info = FileUtils().r_info6(module, "用户名信息", "message3")
print(info)
username1 = info['username1']
# # 请求体 # # 请求体
request_body = commonFuc().get_business_data(module, "payload63_11", orgName) request_body = commonFuc().get_business_data(module, "payload63_11", username1,username1, orgName,username1)
print('request_body', request_body) print('request_body', request_body)
# # # # 发送请求 # # # # 发送请求
result = commonFuc().http_post(url, request_body, headers) result = commonFuc().http_post(url, request_body, headers)
......
...@@ -251,6 +251,47 @@ class FileUtils(object): ...@@ -251,6 +251,47 @@ class FileUtils(object):
# 写入到yaml文件 # 写入到yaml文件
with open(yamlpath, "a", encoding="utf-8") as f: with open(yamlpath, "a", encoding="utf-8") as f:
yaml.dump(dict, f, Dumper=yaml.RoundTripDumper, allow_unicode=True) yaml.dump(dict, f, Dumper=yaml.RoundTripDumper, allow_unicode=True)
def w_info8(self, info,module,keyname,titlename,message_no):
module=module
dict = {}
value = {}
for i in range(len(titlename)):
value[titlename[i]] = info[i]
# value[titlename[0]] = info[0]
# value[titlename[1]] = info[1]
key=keyname
dict[key] = value
w_path=rootPath+os.sep+'data'+os.sep+module
# print(w_path)
yamlpath = os.path.join(w_path, message_no)
if (self.r_info8(module,keyname,message_no)!=None):
print('已有相同信息,覆盖写入')
# 写入到yaml文件
with open(yamlpath, "w", encoding="utf-8") as f:
yaml.dump(dict, f, Dumper=yaml.RoundTripDumper,allow_unicode=True)
else:
# 写入到yaml文件
with open(yamlpath, "a", encoding="utf-8") as f:
yaml.dump(dict, f, Dumper=yaml.RoundTripDumper, allow_unicode=True)
def r_info8(self, module, keyname,message_no):
w_path = rootPath + os.sep + 'data' + os.sep + module
yamlpath = os.path.join(w_path, message_no)
try:
file_value = open(yamlpath, 'r', encoding='utf-8')
except:
file_value = open(yamlpath, 'w', encoding='utf-8')
file_value = open(yamlpath, 'r', encoding='utf-8')
result = yaml.load(file_value.read(), Loader=yaml.Loader)
if result is not None:
key = keyname
if key in result:
return result[key]
else:
return None
else:
return None
if __name__ == '__main__': if __name__ == '__main__':
# info=("aaaa","bbbbbb","mdm3-pim") # info=("aaaa","bbbbbb","mdm3-pim")
# FileUtils().w_info(info,"产品新增") # FileUtils().w_info(info,"产品新增")
......
...@@ -506,9 +506,9 @@ json_headers2: { ...@@ -506,9 +506,9 @@ json_headers2: {
"payload63_6": {"pageNum":1,"pageSize":50,"queryObject":{"cname":"%s","orgName":"","corpId":"h0347"}} "payload63_6": {"pageNum":1,"pageSize":50,"queryObject":{"cname":"%s","orgName":"","corpId":"h0347"}}
"payload63_7": {"pageNum":1,"pageSize":50,"queryObject":{"cname":"xhs1009","roleCode":"ro00442","orgName":"%s","corpId":"h0347"}} "payload63_7": {"pageNum":1,"pageSize":50,"queryObject":{"cname":"xhs1009","roleCode":"ro00442","orgName":"%s","corpId":"h0347"}}
"payload63_8": {"pageNum":1,"pageSize":50,"queryObject":{"cname":"%s","roleCode":"ro00442","orgName":"%s","corpId":"h0347"}} "payload63_8": {"pageNum":1,"pageSize":50,"queryObject":{"cname":"%s","roleCode":"ro00442","orgName":"%s","corpId":"h0347"}}
"payload63_9": {"userCode":"自动化测试%s","cname":"自动化测试%s","tel":"xhs0301","orgCode":"","orgId":"%s","roleCode":"ro00442","projectCode":"herp","erpCode":"自动化测试%s"} "payload63_9": {"userCode":"%s","cname":"%s","tel":"xhs0301","orgCode":"","orgId":"%s","roleCode":"ro00442","projectCode":"herp","erpCode":"%s"}
"payload63_10": {"userCode":"自动化测试","cname":"自动化测试_update","tel":"xhs0301","orgCode":"001","orgId":"%s","id":"h0347_UID-051050","enableFlag":"0","roleCode":"ro00442","projectCode":"herp","erpCode":"自动化测试_update"} "payload63_10": {"userCode":"%s","cname":"%s","tel":"xhs0301","orgCode":"001","orgId":"%s","id":"h0347_UID-051072","enableFlag":"0","roleCode":"ro00442","projectCode":"herp","erpCode":"%s"}
"payload63_11": {"userCode":"自动化测试","cname":"自动化测试_update","tel":"xhs0301","orgCode":"001","orgId":"%s","id":"h0347_UID-051050","enableFlag":"1","roleCode":"ro00442","projectCode":"herp","erpCode":"自动化测试_update"} "payload63_11": {"userCode":"%s","cname":"%s","tel":"xhs0301","orgCode":"001","orgId":"%s","id":"h0347_UID-051072","enableFlag":"1","roleCode":"ro00442","projectCode":"herp","erpCode":"%s_update"}
"payload63_12": {"roleCode":"ro00442","userId":"h0347_UID-051050","projectCode":"herp","grantInfos":[{"corpId":"h0347","corpName":"","mgrBranchId":"h0347-2011","mgrBranchName":"东土城院区","mgrRangeId":"%s","mgrRangeName":"001","roleCode":"ro00442"},{"corpId":"h0347","corpName":"","mgrBranchId":"h0347-2011","mgrBranchName":"东土城院区","mgrRangeId":"%s","mgrRangeName":"008","roleCode":"ro00442"}]} "payload63_12": {"roleCode":"ro00442","userId":"h0347_UID-051050","projectCode":"herp","grantInfos":[{"corpId":"h0347","corpName":"","mgrBranchId":"h0347-2011","mgrBranchName":"东土城院区","mgrRangeId":"%s","mgrRangeName":"001","roleCode":"ro00442"},{"corpId":"h0347","corpName":"","mgrBranchId":"h0347-2011","mgrBranchName":"东土城院区","mgrRangeId":"%s","mgrRangeName":"008","roleCode":"ro00442"}]}
"payload64": {"pageNum":1,"pageSize":50,"queryObject":{"startTime":"","endTime":""}} "payload64": {"pageNum":1,"pageSize":50,"queryObject":{"startTime":"","endTime":""}}
"payload64_1": {"pageNum":1,"pageSize":200,"queryObject":{"methodCode":"S0102","operType":"restful","startTime":"2024-02-28 00:00:00","endTime":"2024-02-29 23:59:59"}} "payload64_1": {"pageNum":1,"pageSize":200,"queryObject":{"methodCode":"S0102","operType":"restful","startTime":"2024-02-28 00:00:00","endTime":"2024-02-29 23:59:59"}}
......
院区新增: 院区新增:
branch_id: h0347-3359 branch_id: h0347-3359
branch_name: 东土城路院区c#YBu branch_name: 东土城路院区c#YBu
用户名信息:
username1: zi!fc
username2: zi!fc
公告新增: 公告新增:
notices_id: N001734-h0347 notices_id: N001734-h0347
notices_name: notices_name:
用户名信息:
username1: LHw!K
username2: LHw!K
...@@ -72,9 +72,9 @@ ...@@ -72,9 +72,9 @@
</tr> </tr>
<tr width="600"> <tr width="600">
<td class="details-col-elapsed"><a href='../log/r_f0用户管理_用户管理_新增用户/log.html' target='_blank'>r_f0用户管理_用户管理_新增用户</a></td> <td class="details-col-elapsed"><a href='../log/r_f3用户管理_用户管理_编辑用户_启用/log.html' target='_blank'>r_f3用户管理_用户管理_编辑用户_启用</a></td>
<td class="success">成功</td> <td class="success">成功</td>
<td class="details-col-elapsed">2.314</td> <td class="details-col-elapsed">2.174</td>
<td class="details-col-elapsed">xiaohesheng</td> <td class="details-col-elapsed">xiaohesheng</td>
</tr> </tr>
......
Supports Markdown
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