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

用例优化

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