Commit f24c132d authored by liguangyu06's avatar liguangyu06
Browse files

用例优化

parent abb044d6
......@@ -22,7 +22,6 @@ password = commonFuc().get_business_data(module, "password4")
cmdc_access_token = CmdcDoLogin(username, password).get_token()
headers = commonFuc().get_business_data(module, "json_headers", cmdc_access_token)
# 第二步查询规格型号
# 随机生成商品规格型号
material_code_input = random.randint(1, 100)
......@@ -34,28 +33,31 @@ request_body = commonFuc().get_business_data(module, "payload5", material_code_i
result = requests.get(url, params=request_body, headers=headers)
result = json.loads(result.content)
# print(result)
# 获取规格型号
specifications = result["data"][1]
# 第三步根据规格型号获取对应的商品列表
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url4")
request_body = commonFuc().get_business_data(module, "payload4", specifications)
"""
场景:根据规格型号获取对应商品列表
用例名称:根据规格型号获取对应商品列表
输出:{"success":true,"code":"200","message":"OK"}
"""
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
result = json.loads(result.content)
# print(result)
result = {"optionStr": result["data"]["list"][0]["optionStr"][:2]}
result["api_time"] = api_time
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict4", specifications[:2])
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# 判断是否获取到规格型号信息
if result["data"]:
# 获取规格型号
specifications = result["data"][1]
# 第三步根据规格型号获取对应的商品列表
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url4")
request_body = commonFuc().get_business_data(module, "payload4", specifications)
"""
场景:根据规格型号获取对应商品列表
用例名称:根据规格型号获取对应商品列表
输出:{"success":true,"code":"200","message":"OK"}
"""
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
# 获取接口响应时间
api_time = float(result.elapsed.total_seconds())
result = json.loads(result.content)
# print(result)
result = {"optionStr": result["data"]["list"][0]["optionStr"][:2]}
result["api_time"] = api_time
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict4", specifications[:2])
# 断言实际结果中是否包含预期结果的内容
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