Commit 2ac4b2b9 authored by liguangyu06's avatar liguangyu06
Browse files

用例优化

parent 0d955981
No related merge requests found
Showing with 33 additions and 31 deletions
+33 -31
......@@ -28,38 +28,40 @@ request_body = commonFuc().get_business_data(module, "payload57")
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
# 生成随机数
product_random = random.randint(0, len(result["data"]["list"]) - 1)
# 获取下单数量设置信息
product_name = result["data"]["list"][product_random]["productName"]
product_code = result["data"]["list"][product_random]["productCode"]
specifications = result["data"]["list"][product_random]["specifications"]
status = result["data"]["list"][product_random]["status"]
# 判断是否获取到下单数量
if result["data"]["list"]:
# 生成随机数
product_random = random.randint(0, len(result["data"]["list"]) - 1)
# 获取下单数量设置信息
product_name = result["data"]["list"][product_random]["productName"]
product_code = result["data"]["list"][product_random]["productCode"]
specifications = result["data"]["list"][product_random]["specifications"]
status = result["data"]["list"][product_random]["status"]
# 进行查询条件验证
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url58")
request_body = commonFuc().get_business_data(module, "payload58", product_name, product_code, specifications, status)
# print(request_body)
"""
场景: 查询条件验证_下单数量列表
用例名称:查询条件验证_下单数量列表
输出:{"productCode":"%s"}
"""
# 进行查询条件验证
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url58")
request_body = commonFuc().get_business_data(module, "payload58", product_name, product_code, specifications, status)
# print(request_body)
"""
场景: 查询条件验证_下单数量列表
用例名称:查询条件验证_下单数量列表
输出:{"productCode":"%s"}
"""
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
result = json.loads(result.content)
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
result = json.loads(result.content)
# print(result)
# 获取查询结果中商品信息
result = {"productCode": result["data"]["list"][0]["productCode"]}
result["api_time"] = api_time
# print(result)
# 获取查询结果中商品信息
result = {"productCode": result["data"]["list"][0]["productCode"]}
result["api_time"] = api_time
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict58", product_code)
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict58", product_code)
# 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