Commit 7cb26823 authored by liguangyu06's avatar liguangyu06
Browse files

优化

parent 9f762ba0
......@@ -51,26 +51,28 @@ api_time = float(result.elapsed.total_seconds())
# 获取商品详情页显示的库存信息
result = json.loads(result.content)
# print(result)
result = {"stockQty": result["data"][0]["stockQty"]}
# 将接口响应时间添加至result
result["api_time"] = api_time
if result["data"]:
# 数据库操作
mysql_handle = mySql()
# 获取conf.ini文件中配置的数据库信息
host, port, user, pwd = mysql_handle.getConf(db="cmdc_db")
result = {"stockQty": result["data"][0]["stockQty"]}
# 查询数据库中商品对应的库存数量
sql = "SELECT sum(t.quantity)/10000 FROM `cmdc-product`.ic_inventory t " \
"WHERE productCode = 10146174 and markForDelete = 0 " \
"and type = 1 and isLimited != 'Y' and expireDate > {}".format(ru_date)
# 将接口响应时间添加至result
result["api_time"] = api_time
total = mysql_handle.selectSql(host, port, user, pwd, "cmdc-product", sql)[0][0]
# 数据库操作
mysql_handle = mySql()
# 获取conf.ini文件中配置的数据库信息
host, port, user, pwd = mysql_handle.getConf(db="cmdc_db")
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict115", int(total))
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
# 查询数据库中商品对应的库存数量
sql = "SELECT sum(t.quantity)/10000 FROM `cmdc-product`.ic_inventory t " \
"WHERE productCode = 10146174 and markForDelete = 0 " \
"and type = 1 and isLimited != 'Y' and expireDate > {}".format(ru_date)
total = mysql_handle.selectSql(host, port, user, pwd, "cmdc-product", sql)[0][0]
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict115", int(total))
# 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