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

优化

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