Commit 5271a37a authored by 周念东's avatar 周念东
Browse files

20240617

parents ced008e1 c3acdd56
...@@ -14,15 +14,18 @@ import json ...@@ -14,15 +14,18 @@ import json
module = "cmdc_demand_creation" module = "cmdc_demand_creation"
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url")
# print(url)
# 获取登录所需账号密码 # 获取登录所需账号密码
username = commonFuc().get_business_data(module, "username") username = commonFuc().get_business_data(module, "username2")
password = commonFuc().get_business_data(module, "password") password = commonFuc().get_business_data(module, "password2")
# 获取登录后Cmdc_access_token # 获取登录后Cmdc_access_token
cmdc_access_token = CmdcDoLogin(username, password).get_token() cmdc_access_token = CmdcDoLogin(username, password).get_token()
headers = commonFuc().get_business_data(module, "json_headers1", cmdc_access_token) headers = commonFuc().get_business_data(module, "json_headers1", cmdc_access_token)
# 进行需求单提交创建
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url")
request_body = commonFuc().get_business_data(module, "payload1") request_body = commonFuc().get_business_data(module, "payload1")
""" """
场景:需求创建 场景:需求创建
用例名称:需求单创建 用例名称:需求单创建
...@@ -30,10 +33,15 @@ request_body = commonFuc().get_business_data(module, "payload1") ...@@ -30,10 +33,15 @@ request_body = commonFuc().get_business_data(module, "payload1")
""" """
# 发送请求 # 发送请求
result = requests.post(url, json=request_body, headers=headers) result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = result.elapsed.total_seconds()
# 获取接口响应时间
api_time = result.elapsed.total_seconds()
result = json.loads(result.content) result = json.loads(result.content)
# print(result) # print(result)
result["api_time"] = api_time
# 获取预期结果 # 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict1") check_dict = commonFuc().get_business_data(module, "checkDict1")
print(check_dict) # print(check_dict)
# 断言实际结果中是否包含预期结果的内容 # 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result) commonFuc().check_result(check_dict, result)
\ No newline at end of file
...@@ -13,14 +13,18 @@ import json ...@@ -13,14 +13,18 @@ import json
module = "cmdc_demand_creation" module = "cmdc_demand_creation"
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url2")
# 获取登录所需账号密码 # 获取登录所需账号密码
username = commonFuc().get_business_data(module, "username") username = commonFuc().get_business_data(module, "username")
password = commonFuc().get_business_data(module, "password") password = commonFuc().get_business_data(module, "password")
# 获取登录后Cmdc_access_token # 获取登录后Cmdc_access_token
cmdc_access_token = CmdcDoLogin(username, password).get_token() cmdc_access_token = CmdcDoLogin(username, password).get_token()
headers = commonFuc().get_business_data(module, "json_headers1", cmdc_access_token) headers = commonFuc().get_business_data(module, "json_headers1", cmdc_access_token)
# 进行草稿订单提交创建
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url2")
request_body = commonFuc().get_business_data(module, "payload2") request_body = commonFuc().get_business_data(module, "payload2")
""" """
场景:需求草稿订单的创建 场景:需求草稿订单的创建
用例名称:需求草稿订单的创建 用例名称:需求草稿订单的创建
...@@ -29,10 +33,21 @@ request_body = commonFuc().get_business_data(module, "payload2") ...@@ -29,10 +33,21 @@ request_body = commonFuc().get_business_data(module, "payload2")
# 发送请求 # 发送请求
result = requests.post(url, json=request_body, headers=headers) result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = result.elapsed.total_seconds()
result = json.loads(result.content) result = json.loads(result.content)
# print(result) result["api_time"] = api_time
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict2") # 判断登录是否成功
print(check_dict) if result["success"]:
# 断言实际结果中是否包含预期结果的内容 # 获取预期结果
commonFuc().check_result(check_dict, result) check_dict = commonFuc().get_business_data(module, "checkDict2")
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
else:
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict_fail")
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
...@@ -15,7 +15,7 @@ import random ...@@ -15,7 +15,7 @@ import random
module = "cmdc_demand_delete" module = "cmdc_demand_delete"
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url")
# 获取登录所需账号密码 # 获取登录所需账号密码
username = commonFuc().get_business_data(module, "username") username = commonFuc().get_business_data(module, "username")
password = commonFuc().get_business_data(module, "password") password = commonFuc().get_business_data(module, "password")
...@@ -24,6 +24,9 @@ cmdc_access_token = CmdcDoLogin(username, password).get_token() ...@@ -24,6 +24,9 @@ cmdc_access_token = CmdcDoLogin(username, password).get_token()
headers = commonFuc().get_business_data(module, "json_headers1", cmdc_access_token) headers = commonFuc().get_business_data(module, "json_headers1", cmdc_access_token)
# 随机生成不存在的需求单id # 随机生成不存在的需求单id
demand_id = random.randint(10000000000000, 1000000000000000) demand_id = random.randint(10000000000000, 1000000000000000)
# 进行需求单的删除
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url")
request_body = commonFuc().get_business_data(module, "payload2", demand_id) request_body = commonFuc().get_business_data(module, "payload2", demand_id)
""" """
...@@ -34,8 +37,11 @@ request_body = commonFuc().get_business_data(module, "payload2", demand_id) ...@@ -34,8 +37,11 @@ request_body = commonFuc().get_business_data(module, "payload2", demand_id)
# 发送请求 # 发送请求
result = requests.post(url, json=request_body, headers=headers) result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = result.elapsed.total_seconds()
result = json.loads(result.content) result = json.loads(result.content)
# print(result) result["api_time"] = api_time
# 获取预期结果 # 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict3") check_dict = commonFuc().get_business_data(module, "checkDict3")
print(check_dict) print(check_dict)
......
...@@ -44,8 +44,11 @@ request_body = commonFuc().get_business_data(module, "payload4", demand_id) ...@@ -44,8 +44,11 @@ request_body = commonFuc().get_business_data(module, "payload4", demand_id)
# 发送请求 # 发送请求
result = requests.post(url, json=request_body, headers=headers) result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = result.elapsed.total_seconds()
result = json.loads(result.content) result = json.loads(result.content)
# print(result) result["api_time"] = api_time
# 获取预期结果 # 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict5") check_dict = commonFuc().get_business_data(module, "checkDict5")
print(check_dict) print(check_dict)
......
...@@ -73,8 +73,11 @@ request_body3 = commonFuc().get_business_data(module, "payload3", demand_id) ...@@ -73,8 +73,11 @@ request_body3 = commonFuc().get_business_data(module, "payload3", demand_id)
# 发送请求 # 发送请求
result3 = requests.post(url3, json=request_body3, headers=headers) result3 = requests.post(url3, json=request_body3, headers=headers)
# 获取接口响应时间
api_time = result3.elapsed.total_seconds()
result3 = json.loads(result3.content) result3 = json.loads(result3.content)
# print(result) result3["api_time"] = api_time
# 获取预期结果 # 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict4") check_dict = commonFuc().get_business_data(module, "checkDict4")
print(check_dict) print(check_dict)
......
...@@ -27,7 +27,10 @@ url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url_dem ...@@ -27,7 +27,10 @@ url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url_dem
request_body = commonFuc().get_business_data(module, "payload_demand") request_body = commonFuc().get_business_data(module, "payload_demand")
# 发送请求 # 发送请求
result = requests.post(url, json=request_body, headers=headers) result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = result.elapsed.total_seconds()
result = json.loads(result.content) result = json.loads(result.content)
result["api_time"] = api_time
# 频繁创建需求单会创建失败,因此添加了判断 # 频繁创建需求单会创建失败,因此添加了判断
if result["code"] == "200": if result["code"] == "200":
...@@ -51,7 +54,7 @@ if result["code"] == "200": ...@@ -51,7 +54,7 @@ if result["code"] == "200":
# print(result1) # print(result1)
# 获取demandId # 获取demandId
demand_id = result1["data"]["list"][0]["demandId"] demand_id = result1["data"]["list"][0]["demandId"]
print(demand_id) # print(demand_id)
# 第三步删除操作 # 第三步删除操作
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url") url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url")
...@@ -66,8 +69,10 @@ if result["code"] == "200": ...@@ -66,8 +69,10 @@ if result["code"] == "200":
# 发送请求 # 发送请求
result = requests.post(url, json=request_body, headers=headers) result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = result.elapsed.total_seconds()
result = json.loads(result.content) result = json.loads(result.content)
print(result) result["api_time"] = api_time
# 获取预期结果 # 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict2") check_dict = commonFuc().get_business_data(module, "checkDict2")
# 断言实际结果中是否包含预期结果的内容 # 断言实际结果中是否包含预期结果的内容
......
...@@ -15,7 +15,7 @@ import random ...@@ -15,7 +15,7 @@ import random
module = "cmdc_demand_fail" module = "cmdc_demand_fail"
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url")
# 获取登录所需账号密码 # 获取登录所需账号密码
username = commonFuc().get_business_data(module, "username") username = commonFuc().get_business_data(module, "username")
password = commonFuc().get_business_data(module, "password") password = commonFuc().get_business_data(module, "password")
...@@ -24,6 +24,9 @@ cmdc_access_token = CmdcDoLogin(username, password).get_token() ...@@ -24,6 +24,9 @@ cmdc_access_token = CmdcDoLogin(username, password).get_token()
headers = commonFuc().get_business_data(module, "json_headers1", cmdc_access_token) headers = commonFuc().get_business_data(module, "json_headers1", cmdc_access_token)
# 随机生成不存在的需求单id # 随机生成不存在的需求单id
demand_id = random.randint(100000000000, 100000000000000) demand_id = random.randint(100000000000, 100000000000000)
# 进行需求单的审核处理
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url")
request_body = commonFuc().get_business_data(module, "payload3", demand_id) request_body = commonFuc().get_business_data(module, "payload3", demand_id)
""" """
...@@ -34,10 +37,13 @@ request_body = commonFuc().get_business_data(module, "payload3", demand_id) ...@@ -34,10 +37,13 @@ request_body = commonFuc().get_business_data(module, "payload3", demand_id)
# 发送请求 # 发送请求
result = requests.post(url, json=request_body, headers=headers) result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = result.elapsed.total_seconds()
result = json.loads(result.content) result = json.loads(result.content)
# print(result) result["api_time"] = api_time
# 获取预期结果 # 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict3") check_dict = commonFuc().get_business_data(module, "checkDict3")
print(check_dict) # print(check_dict)
# 断言实际结果中是否包含预期结果的内容 # 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result) commonFuc().check_result(check_dict, result)
...@@ -17,8 +17,8 @@ module = "cmdc_demand_fail" ...@@ -17,8 +17,8 @@ module = "cmdc_demand_fail"
# 第一步登录后台运营平台获取cmdc_access_token # 第一步登录后台运营平台获取cmdc_access_token
# 获取登录所需账号密码 # 获取登录所需账号密码
username = commonFuc().get_business_data(module, "username") username = commonFuc().get_business_data(module, "username1")
password = commonFuc().get_business_data(module, "password") password = commonFuc().get_business_data(module, "password1")
# 获取登录后Cmdc_access_token # 获取登录后Cmdc_access_token
cmdc_access_token = CmdcDoLogin(username, password).get_token() cmdc_access_token = CmdcDoLogin(username, password).get_token()
headers = commonFuc().get_business_data(module, "json_headers1", cmdc_access_token) headers = commonFuc().get_business_data(module, "json_headers1", cmdc_access_token)
...@@ -29,24 +29,31 @@ request_body = commonFuc().get_business_data(module, "payload40") ...@@ -29,24 +29,31 @@ request_body = commonFuc().get_business_data(module, "payload40")
# 发送请求 # 发送请求
result = requests.post(url1, json=request_body, headers=headers) result = requests.post(url1, json=request_body, headers=headers)
result = json.loads(result.content) result = json.loads(result.content)
# 获取demandId
demand_id = result["data"]["list"][0]["demandId"]
# 第三步进行审核操作
url1 = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url")
request_body1 = commonFuc().get_business_data(module, "payload4", demand_id)
""" # 判断是否存在其他状态的需求单
场景:审核其他状态下的需求单 if result["data"]["list"]:
用例名称:审核其他状态下的需求单 # 获取demandId
输出:{"success":true,"code":"200","message":"OK","data":1} demand_id = result["data"]["list"][0]["demandId"]
"""
# 第三步进行审核操作
# 发送请求 url1 = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url")
result1 = requests.post(url1, json=request_body1, headers=headers) request_body1 = commonFuc().get_business_data(module, "payload4", demand_id)
result1 = json.loads(result1.content)
# print(result1) """
# 获取预期结果 场景:审核其他状态下的需求单
check_dict = commonFuc().get_business_data(module, "checkDict4") 用例名称:审核其他状态下的需求单
print(check_dict) 输出:{"success":true,"code":"200","message":"OK","data":1}
# 断言实际结果中是否包含预期结果的内容 """
commonFuc().check_result(check_dict, result1)
# 发送请求
result1 = requests.post(url1, json=request_body1, headers=headers)
# 获取接口响应时间
api_time = result1.elapsed.total_seconds()
result1 = json.loads(result1.content)
result1["api_time"] = api_time
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict4")
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result1)
...@@ -16,8 +16,8 @@ module = "cmdc_demand_fail" ...@@ -16,8 +16,8 @@ module = "cmdc_demand_fail"
# 第一步登录后台运营平台获取cmdc_access_token # 第一步登录后台运营平台获取cmdc_access_token
# 获取登录所需账号密码 # 获取登录所需账号密码
username = commonFuc().get_business_data(module, "username") username = commonFuc().get_business_data(module, "username1")
password = commonFuc().get_business_data(module, "password") password = commonFuc().get_business_data(module, "password1")
# 获取登录后Cmdc_access_token # 获取登录后Cmdc_access_token
cmdc_access_token = CmdcDoLogin(username, password).get_token() cmdc_access_token = CmdcDoLogin(username, password).get_token()
headers = commonFuc().get_business_data(module, "json_headers1", cmdc_access_token) headers = commonFuc().get_business_data(module, "json_headers1", cmdc_access_token)
...@@ -49,10 +49,13 @@ request_body3 = commonFuc().get_business_data(module, "payload2", demand_id) ...@@ -49,10 +49,13 @@ request_body3 = commonFuc().get_business_data(module, "payload2", demand_id)
""" """
# 发送请求 # 发送请求
result3 = requests.post(url3, json=request_body3, headers=headers) result3 = requests.post(url3, json=request_body3, headers=headers)
# 获取接口响应时间
api_time = result3.elapsed.total_seconds()
result3 = json.loads(result3.content) result3 = json.loads(result3.content)
# print(result3) result3["api_time"] = api_time
# 获取预期结果 # 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict2") check_dict = commonFuc().get_business_data(module, "checkDict2")
print(check_dict) # print(check_dict)
# 断言实际结果中是否包含预期结果的内容 # 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result3) commonFuc().check_result(check_dict, result3)
...@@ -15,8 +15,8 @@ module = "cmdc_demand_fail" ...@@ -15,8 +15,8 @@ module = "cmdc_demand_fail"
# 第一步登录后台运营平台获取cmdc_access_token # 第一步登录后台运营平台获取cmdc_access_token
# 获取登录所需账号密码 # 获取登录所需账号密码
username = commonFuc().get_business_data(module, "username") username = commonFuc().get_business_data(module, "username1")
password = commonFuc().get_business_data(module, "password") password = commonFuc().get_business_data(module, "password1")
# 获取登录后Cmdc_access_token # 获取登录后Cmdc_access_token
cmdc_access_token = CmdcDoLogin(username, password).get_token() cmdc_access_token = CmdcDoLogin(username, password).get_token()
headers = commonFuc().get_business_data(module, "json_headers1", cmdc_access_token) headers = commonFuc().get_business_data(module, "json_headers1", cmdc_access_token)
...@@ -42,10 +42,13 @@ request_body1 = commonFuc().get_business_data(module, "payload1", demand_id) ...@@ -42,10 +42,13 @@ request_body1 = commonFuc().get_business_data(module, "payload1", demand_id)
# 发送请求 # 发送请求
result1 = requests.post(url1, json=request_body1, headers=headers) result1 = requests.post(url1, json=request_body1, headers=headers)
# 获取接口响应时间
api_time = result1.elapsed.total_seconds()
result1 = json.loads(result1.content) result1 = json.loads(result1.content)
# print(result1) result1["api_time"] = api_time
# 获取预期结果 # 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict1") check_dict = commonFuc().get_business_data(module, "checkDict1")
print(check_dict) # print(check_dict)
# 断言实际结果中是否包含预期结果的内容 # 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result1) commonFuc().check_result(check_dict, result1)
...@@ -14,13 +14,16 @@ import json ...@@ -14,13 +14,16 @@ import json
module = "cmdc_demand_list" module = "cmdc_demand_list"
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url1")
# 获取登录所需账号密码 # 获取登录所需账号密码
username = commonFuc().get_business_data(module, "username") username = commonFuc().get_business_data(module, "username")
password = commonFuc().get_business_data(module, "password") password = commonFuc().get_business_data(module, "password")
# 获取登录后Cmdc_access_token # 获取登录后Cmdc_access_token
cmdc_access_token = CmdcDoLogin(username, password).get_token() cmdc_access_token = CmdcDoLogin(username, password).get_token()
headers = commonFuc().get_business_data(module, "json_headers1", cmdc_access_token) headers = commonFuc().get_business_data(module, "json_headers1", cmdc_access_token)
# 获取需求单列表
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url1")
request_body = commonFuc().get_business_data(module, "payload1") request_body = commonFuc().get_business_data(module, "payload1")
""" """
...@@ -31,11 +34,14 @@ request_body = commonFuc().get_business_data(module, "payload1") ...@@ -31,11 +34,14 @@ request_body = commonFuc().get_business_data(module, "payload1")
# 发送请求 # 发送请求
result = requests.post(url, json=request_body, headers=headers) result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = result.elapsed.total_seconds()
result = json.loads(result.content) result = json.loads(result.content)
# print(result) result["api_time"] = api_time
# 获取预期结果 # 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict2") check_dict = commonFuc().get_business_data(module, "checkDict2")
print(check_dict) # print(check_dict)
# 断言实际结果中是否包含预期结果的内容 # 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result) commonFuc().check_result(check_dict, result)
...@@ -55,10 +55,13 @@ request_body = commonFuc().get_business_data(module, "payload3", demand_id) ...@@ -55,10 +55,13 @@ request_body = commonFuc().get_business_data(module, "payload3", demand_id)
# 发送请求 # 发送请求
result = requests.get(url, params=request_body, headers=headers) result = requests.get(url, params=request_body, headers=headers)
# 获取接口响应时间
api_time = result.elapsed.total_seconds()
result = json.loads(result.content) result = json.loads(result.content)
# print(result) result["api_time"] = api_time
# 获取预期结果 # 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict4") check_dict = commonFuc().get_business_data(module, "checkDict4")
print(check_dict) # print(check_dict)
# 断言实际结果中是否包含预期结果的内容 # 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result) commonFuc().check_result(check_dict, result)
...@@ -49,10 +49,13 @@ request_body = commonFuc().get_business_data(module, "payload2", demand_id) ...@@ -49,10 +49,13 @@ request_body = commonFuc().get_business_data(module, "payload2", demand_id)
""" """
# 发送请求 # 发送请求
result = requests.get(url, params=request_body, headers=headers) result = requests.get(url, params=request_body, headers=headers)
# 获取接口响应时间
api_time = result.elapsed.total_seconds()
result = json.loads(result.content) result = json.loads(result.content)
# print(result) result["api_time"] = api_time
# 获取预期结果 # 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict3") check_dict = commonFuc().get_business_data(module, "checkDict3")
print(check_dict) # print(check_dict)
# 断言实际结果中是否包含预期结果的内容 # 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result) commonFuc().check_result(check_dict, result)
...@@ -13,8 +13,11 @@ import json ...@@ -13,8 +13,11 @@ import json
module = "cmdc_demand_list" module = "cmdc_demand_list"
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url1") # 获取已失效的token
headers = commonFuc().get_business_data(module, "json_headers") headers = commonFuc().get_business_data(module, "json_headers")
# 获取需求单列表
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url1")
request_body = commonFuc().get_business_data(module, "payload") request_body = commonFuc().get_business_data(module, "payload")
""" """
...@@ -25,10 +28,13 @@ request_body = commonFuc().get_business_data(module, "payload") ...@@ -25,10 +28,13 @@ request_body = commonFuc().get_business_data(module, "payload")
# 发送请求 # 发送请求
result = requests.post(url, json=request_body, headers=headers) result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = result.elapsed.total_seconds()
result = json.loads(result.content) result = json.loads(result.content)
# print(result) result["api_time"] = api_time
# 获取预期结果 # 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict1") check_dict = commonFuc().get_business_data(module, "checkDict1")
print(check_dict) # print(check_dict)
# 断言实际结果中是否包含预期结果的内容 # 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result) commonFuc().check_result(check_dict, result)
\ No newline at end of file
...@@ -15,13 +15,15 @@ import json ...@@ -15,13 +15,15 @@ import json
module = "cmdc_demand_list_pc" module = "cmdc_demand_list_pc"
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url1")
# 获取登录所需账号密码 # 获取登录所需账号密码
username = commonFuc().get_business_data(module, "username") username = commonFuc().get_business_data(module, "username")
password = commonFuc().get_business_data(module, "password") password = commonFuc().get_business_data(module, "password")
# 获取登录后Cmdc_access_token # 获取登录后Cmdc_access_token
cmdc_access_token = CmdcMaiiLogin(username, password).get_token() cmdc_access_token = CmdcMaiiLogin(username, password).get_token()
headers = commonFuc().get_business_data(module, "json_headers1", cmdc_access_token) headers = commonFuc().get_business_data(module, "json_headers1", cmdc_access_token)
# 获取需求单列表
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url1")
request_body = commonFuc().get_business_data(module, "payload1") request_body = commonFuc().get_business_data(module, "payload1")
""" """
...@@ -32,10 +34,12 @@ request_body = commonFuc().get_business_data(module, "payload1") ...@@ -32,10 +34,12 @@ request_body = commonFuc().get_business_data(module, "payload1")
# 发送请求 # 发送请求
result = requests.post(url, json=request_body, headers=headers) result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = result.elapsed.total_seconds()
result = json.loads(result.content) result = json.loads(result.content)
# print(result) result["api_time"] = api_time
# 获取预期结果 # 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict1") check_dict = commonFuc().get_business_data(module, "checkDict1")
print(check_dict) # print(check_dict)
# 断言实际结果中是否包含预期结果的内容 # 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result) commonFuc().check_result(check_dict, result)
...@@ -20,12 +20,14 @@ password = commonFuc().get_business_data(module, "password") ...@@ -20,12 +20,14 @@ password = commonFuc().get_business_data(module, "password")
# 获取登录后Cmdc_access_token # 获取登录后Cmdc_access_token
cmdc_access_token = CmdcMaiiLogin(username, password).get_token() cmdc_access_token = CmdcMaiiLogin(username, password).get_token()
headers = commonFuc().get_business_data(module, "json_headers", cmdc_access_token) headers = commonFuc().get_business_data(module, "json_headers", cmdc_access_token)
# 获取需求单列表查询待客户确认需求单 # 获取需求单列表查询待客户确认需求单
url1 = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url1") url1 = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url1")
request_body = commonFuc().get_business_data(module, "payload50") request_body = commonFuc().get_business_data(module, "payload50")
# 发送请求 # 发送请求
result = requests.post(url1, json=request_body, headers=headers) result = requests.post(url1, json=request_body, headers=headers)
result = json.loads(result.content) result = json.loads(result.content)
# 获取需求单信息
demand_parent_id = result["data"]["list"][0]["demandParentId"] demand_parent_id = result["data"]["list"][0]["demandParentId"]
demand_id = result["data"]["list"][0]["demandId"] demand_id = result["data"]["list"][0]["demandId"]
...@@ -40,10 +42,12 @@ request_body = commonFuc().get_business_data(module, "payload5", demand_parent_i ...@@ -40,10 +42,12 @@ request_body = commonFuc().get_business_data(module, "payload5", demand_parent_i
""" """
# 发送请求 # 发送请求
result = requests.post(url, json=request_body, headers=headers) result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = result.elapsed.total_seconds()
result = json.loads(result.content) result = json.loads(result.content)
# print(result) result["api_time"] = api_time
# 获取预期结果 # 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict5") check_dict = commonFuc().get_business_data(module, "checkDict5")
print(check_dict) # print(check_dict)
# 断言实际结果中是否包含预期结果的内容 # 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result) commonFuc().check_result(check_dict, result)
...@@ -20,12 +20,14 @@ password = commonFuc().get_business_data(module, "password") ...@@ -20,12 +20,14 @@ password = commonFuc().get_business_data(module, "password")
# 获取登录后Cmdc_access_token # 获取登录后Cmdc_access_token
cmdc_access_token = CmdcMaiiLogin(username, password).get_token() cmdc_access_token = CmdcMaiiLogin(username, password).get_token()
headers = commonFuc().get_business_data(module, "json_headers", cmdc_access_token) headers = commonFuc().get_business_data(module, "json_headers", cmdc_access_token)
# 获取需求单列表查询待客户确认需求单 # 获取需求单列表查询待客户确认需求单
url1 = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url1") url1 = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url1")
request_body = commonFuc().get_business_data(module, "payload40") request_body = commonFuc().get_business_data(module, "payload40")
# 发送请求 # 发送请求
result = requests.post(url1, json=request_body, headers=headers) result = requests.post(url1, json=request_body, headers=headers)
result = json.loads(result.content) result = json.loads(result.content)
# 获取需求单信息
demand_parent_id = result["data"]["list"][0]["demandParentId"] demand_parent_id = result["data"]["list"][0]["demandParentId"]
demand_id = result["data"]["list"][0]["demandId"] demand_id = result["data"]["list"][0]["demandId"]
...@@ -40,10 +42,12 @@ request_body = commonFuc().get_business_data(module, "payload4", demand_parent_i ...@@ -40,10 +42,12 @@ request_body = commonFuc().get_business_data(module, "payload4", demand_parent_i
""" """
# 发送请求 # 发送请求
result = requests.post(url, json=request_body, headers=headers) result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = result.elapsed.total_seconds()
result = json.loads(result.content) result = json.loads(result.content)
# print(result) result["api_time"] = api_time
# 获取预期结果 # 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict4") check_dict = commonFuc().get_business_data(module, "checkDict4")
print(check_dict) # print(check_dict)
# 断言实际结果中是否包含预期结果的内容 # 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result) commonFuc().check_result(check_dict, result)
...@@ -48,10 +48,12 @@ request_body = commonFuc().get_business_data(module, "payload3", demand_parent_i ...@@ -48,10 +48,12 @@ request_body = commonFuc().get_business_data(module, "payload3", demand_parent_i
""" """
# 发送请求 # 发送请求
result = requests.get(url, params=request_body, headers=headers) result = requests.get(url, params=request_body, headers=headers)
# 获取接口响应时间
api_time = result.elapsed.total_seconds()
result = json.loads(result.content) result = json.loads(result.content)
result["api_time"] = api_time
# 获取预期结果 # 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict3") check_dict = commonFuc().get_business_data(module, "checkDict3")
# 断言实际结果中是否包含预期结果的内容 # 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result) commonFuc().check_result(check_dict, result)
...@@ -26,6 +26,8 @@ request_body = commonFuc().get_business_data(module, "payload20") ...@@ -26,6 +26,8 @@ request_body = commonFuc().get_business_data(module, "payload20")
# 发送请求 # 发送请求
result = requests.post(url1, json=request_body, headers=headers) result = requests.post(url1, json=request_body, headers=headers)
result = json.loads(result.content) result = json.loads(result.content)
# 获取到需求单信息
demand_code = result["data"]["list"][0]["demandCode"] demand_code = result["data"]["list"][0]["demandCode"]
# 获取需求单进行取消操作 # 获取需求单进行取消操作
...@@ -39,10 +41,13 @@ request_body = commonFuc().get_business_data(module, "payload2", demand_code) ...@@ -39,10 +41,13 @@ request_body = commonFuc().get_business_data(module, "payload2", demand_code)
""" """
# 发送请求 # 发送请求
result = requests.post(url, json=request_body, headers=headers) result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = result.elapsed.total_seconds()
result = json.loads(result.content) result = json.loads(result.content)
# print(result) result["api_time"] = api_time
# 获取预期结果 # 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict2") check_dict = commonFuc().get_business_data(module, "checkDict2")
print(check_dict) # print(check_dict)
# 断言实际结果中是否包含预期结果的内容 # 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result) commonFuc().check_result(check_dict, result)
# -*- encoding=utf8 -*-
__author__ = "liguangyu"
"""
case_tag:cmdc_api,cmdc上传支付凭证功能验证,2289,2289-33,sit,bs
涉及到接口:多采商城支付页面附件上传接口
"""
from common.common_func import commonFuc
from air_case.cmdc_login.多采商城登录.多采商城登录 import CmdcMaiiLogin
import requests
import json
import os
module = "cmdc_demand_mall"
# 第一步登录多采商城获取token
# 获取登录所需账号密码
username = commonFuc().get_business_data(module, "username")
password = commonFuc().get_business_data(module, "password")
# 获取登录后Cmdc_access_token
cmdc_access_token = CmdcMaiiLogin(username, password).get_token()
headers = commonFuc().get_business_data(module, "json_headers1", cmdc_access_token)
# 获取文件地址
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
file_path = BASE_DIR + "/data/cmdc_files/test_file.jpg"
# 第二步上传附件
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url34")
# 获取文件
file = open(file_path, "rb")
files = {"file": file}
"""
场景: 上传支付凭证功能验证
用例名称:上传支付凭证功能验证
输出:{"success":true,"code":"200","message":"OK"}
"""
# 发送请求
result = requests.post(url, files=files, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
result = json.loads(result.content)
result["api_time"] = api_time
# print(result)
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict34")
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
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