Commit 22ea88d8 authored by liguangyu06's avatar liguangyu06
Browse files

用例优化

parent 0f82bd72
......@@ -37,17 +37,19 @@ result = json.loads(result.content)
# 获取套包协议特价总数量
result = {"total": result["data"]["total"]}
print(result)
# 数据库操作
mysql_handle = mySql()
# 获取conf.ini文件中配置的数据库信息
host, port, user, pwd = mysql_handle.getConf(db="cmdc_db")
# 数据库查询套包正价数量
sql = "SELECT t.groupId FROM `cmdc-order`.tc_fresenius_agreement_price t " \
"WHERE isRegularPrice = 0 and groupPriceStatus = 1 and companyCode = 00111"
# 数据库查询协议价套包数量(套包存在且非停用下架状态,不是正价套包即isRegularPrice = 0)
sql = "SELECT t.* FROM `cmdc-order`.tc_fresenius_agreement_price t " \
"WHERE companyCode = 00111 and isRegularPrice = 0 and " \
"groupId in (SELECT t.groupId FROM `cmdc-order`.tc_fresenius_group t " \
"WHERE status = 1 and groupType = 0);"
total = len(mysql_handle.selectSql(host, port, user, pwd, "cmdc-order", sql))
print(total)
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict3", total)
# 断言实际结果中是否包含预期结果的内容
......
......@@ -36,12 +36,10 @@ result = requests.post(url, headers=headers, json=request_body)
result = json.loads(result.content)
# 随机获取不相同两个商品信息
product_id_a = random.randint(1, len(result["data"]["list"]) - 2)
print(product_id_a)
product_id_a = random.randint(1, len(result["data"]["list"]) - 1)
product_code_a = result["data"]["list"][product_id_a]["productCode"]
product_name_a = result["data"]["list"][product_id_a]["productName"]
product_id_b = random.randint(product_id_a, len(result["data"]["list"])-1)
print(product_id_b)
product_id_b = random.randint(product_id_a + 1, len(result["data"]["list"]))
product_code_b = result["data"]["list"][product_id_b]["productCode"]
product_name_b = result["data"]["list"][product_id_b]["productName"]
......@@ -85,4 +83,3 @@ print(result)
check_dict = commonFuc().get_business_data(module, "checkDict12")
# 断言实际结果中是否包含预期结果的内容
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