Commit 0d59ae7e authored by liguangyu06's avatar liguangyu06
Browse files

用例优化

parent c93ee8c9
...@@ -22,13 +22,26 @@ password = commonFuc().get_business_data(module, "password1") ...@@ -22,13 +22,26 @@ password = commonFuc().get_business_data(module, "password1")
cmdc_access_token = CmdcDoLogin(username, password).get_token() cmdc_access_token = CmdcDoLogin(username, password).get_token()
headers = commonFuc().get_business_data(module, "json_headers", cmdc_access_token) headers = commonFuc().get_business_data(module, "json_headers", cmdc_access_token)
# 第二步获取获取可使用商品返利清单 # 第二步获取返利发放明细
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url35") url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url33")
request_body = commonFuc().get_business_data(module, "payload35") request_body = commonFuc().get_business_data(module, "payload33")
# 发送请求 # 发送请求
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)
# 生成一个随机数
rebate_random = random.randint(0, len(result["data"]["list"]) - 1)
# 获取返利规则信息
rebate_trip_td = result["data"]["list"][rebate_random]["rebateTripId"]
# 第三步获取获取可使用商品返利清单列表
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url35")
request_body = commonFuc().get_business_data(module, "payload35", rebate_trip_td)
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
# print(result)
# 生成一个随机数字 # 生成一个随机数字
product_random = random.randint(0, len(result["data"]["list"]) - 1) product_random = random.randint(0, len(result["data"]["list"]) - 1)
# 获取获取可使用商品返利清单信息 # 获取获取可使用商品返利清单信息
...@@ -37,7 +50,7 @@ product_code = result["data"]["list"][product_random]["productCode"] ...@@ -37,7 +50,7 @@ product_code = result["data"]["list"][product_random]["productCode"]
specifications = result["data"]["list"][product_random]["specifications"] specifications = result["data"]["list"][product_random]["specifications"]
manufacturer = result["data"]["list"][product_random]["manufacturer"] manufacturer = result["data"]["list"][product_random]["manufacturer"]
# 第步进行可使用商品返利清单查询 # 第步进行可使用商品返利清单查询
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url36") url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url36")
request_body = commonFuc().get_business_data(module, "payload36", product_name, product_code, specifications, request_body = commonFuc().get_business_data(module, "payload36", product_name, product_code, specifications,
manufacturer) manufacturer)
......
...@@ -22,9 +22,22 @@ password = commonFuc().get_business_data(module, "password1") ...@@ -22,9 +22,22 @@ password = commonFuc().get_business_data(module, "password1")
cmdc_access_token = CmdcDoLogin(username, password).get_token() cmdc_access_token = CmdcDoLogin(username, password).get_token()
headers = commonFuc().get_business_data(module, "json_headers", cmdc_access_token) headers = commonFuc().get_business_data(module, "json_headers", cmdc_access_token)
# 第二步获取获取可发放客户清单 # 第二步获取返利发放明细
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url33")
request_body = commonFuc().get_business_data(module, "payload33")
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
# 生成一个随机数
rebate_random = random.randint(0, len(result["data"]["list"]) - 1)
# 获取返利规则信息
rebate_trip_td = result["data"]["list"][rebate_random]["rebateTripId"]
# 第三步获取获取可发放客户清单
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url37") url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url37")
request_body = commonFuc().get_business_data(module, "payload37") request_body = commonFuc().get_business_data(module, "payload37", rebate_trip_td)
# 发送请求 # 发送请求
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)
...@@ -35,10 +48,10 @@ product_random = random.randint(0, len(result["data"]["list"]) - 1) ...@@ -35,10 +48,10 @@ product_random = random.randint(0, len(result["data"]["list"]) - 1)
customer_name = result["data"]["list"][product_random]["customerName"] customer_name = result["data"]["list"][product_random]["customerName"]
customer_code = result["data"]["list"][product_random]["customerCode"] customer_code = result["data"]["list"][product_random]["customerCode"]
# 第步进行可发放客户清单查询 # 第步进行可发放客户清单查询
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url38") url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url38")
request_body = commonFuc().get_business_data(module, "payload38", customer_name, customer_code) request_body = commonFuc().get_business_data(module, "payload38", customer_name, customer_code)
print(request_body)
""" """
场景: 列表查询条件验证_可发放客户清单 场景: 列表查询条件验证_可发放客户清单
用例名称:列表查询条件验证_可发放客户清单 用例名称:列表查询条件验证_可发放客户清单
...@@ -48,7 +61,7 @@ request_body = commonFuc().get_business_data(module, "payload38", customer_name, ...@@ -48,7 +61,7 @@ request_body = commonFuc().get_business_data(module, "payload38", customer_name,
# 发送请求 # 发送请求
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)
# print(result) print(result)
# 获取查询结果中可发放客户清单信息 # 获取查询结果中可发放客户清单信息
result = {"customerCode": result["data"]["list"][0]["customerCode"]} result = {"customerCode": result["data"]["list"][0]["customerCode"]}
...@@ -56,4 +69,3 @@ result = {"customerCode": result["data"]["list"][0]["customerCode"]} ...@@ -56,4 +69,3 @@ result = {"customerCode": result["data"]["list"][0]["customerCode"]}
check_dict = commonFuc().get_business_data(module, "checkDict38", customer_code) check_dict = commonFuc().get_business_data(module, "checkDict38", customer_code)
# 断言实际结果中是否包含预期结果的内容 # 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result) commonFuc().check_result(check_dict, result)
...@@ -22,13 +22,26 @@ password = commonFuc().get_business_data(module, "password1") ...@@ -22,13 +22,26 @@ password = commonFuc().get_business_data(module, "password1")
cmdc_access_token = CmdcDoLogin(username, password).get_token() cmdc_access_token = CmdcDoLogin(username, password).get_token()
headers = commonFuc().get_business_data(module, "json_headers", cmdc_access_token) headers = commonFuc().get_business_data(module, "json_headers", cmdc_access_token)
# 第二步获取商品黑名单 # 第二步获取返利规则
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url11") url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url3")
request_body = commonFuc().get_business_data(module, "payload11") request_body = commonFuc().get_business_data(module, "payload3")
# 发送请求 # 发送请求
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)
# print(result)
# 生成一个随机数
rebate_random = random.randint(0, len(result["data"]["list"]) - 1)
# 获取返利规则信息
rebate_id = result["data"]["list"][rebate_random]["rebateid"]
# 第三步获取商品黑名单
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url11")
request_body = commonFuc().get_business_data(module, "payload11", rebate_id)
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
# print(result)
# 生成一个随机数字,用于后续随机选择商品 # 生成一个随机数字,用于后续随机选择商品
product_random = random.randint(0, len(result["data"]["list"]) - 1) product_random = random.randint(0, len(result["data"]["list"]) - 1)
# 获取商品黑名单中商品信息 # 获取商品黑名单中商品信息
...@@ -37,7 +50,7 @@ product_code = result["data"]["list"][product_random]["productcode"] ...@@ -37,7 +50,7 @@ product_code = result["data"]["list"][product_random]["productcode"]
specifications = result["data"]["list"][product_random]["specifications"] specifications = result["data"]["list"][product_random]["specifications"]
manufacturer = result["data"]["list"][product_random]["manufacturer"] manufacturer = result["data"]["list"][product_random]["manufacturer"]
# 第步进行条件查询验证 # 第步进行条件查询验证
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url12") url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url12")
request_body = commonFuc().get_business_data(module, "payload12", product_name, product_code, specifications, request_body = commonFuc().get_business_data(module, "payload12", product_name, product_code, specifications,
manufacturer) manufacturer)
......
...@@ -22,9 +22,22 @@ password = commonFuc().get_business_data(module, "password1") ...@@ -22,9 +22,22 @@ password = commonFuc().get_business_data(module, "password1")
cmdc_access_token = CmdcDoLogin(username, password).get_token() cmdc_access_token = CmdcDoLogin(username, password).get_token()
headers = commonFuc().get_business_data(module, "json_headers", cmdc_access_token) headers = commonFuc().get_business_data(module, "json_headers", cmdc_access_token)
# 第二步获取返利规则对应的客户范围 # 第二步获取返利规则
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url3")
request_body = commonFuc().get_business_data(module, "payload3")
# 发送请求
result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content)
# 生成一个随机数
rebate_random = random.randint(0, len(result["data"]["list"]) - 1)
# 获取返利规则信息
rebate_id = result["data"]["list"][rebate_random]["rebateid"]
# 第三步获取返利规则对应的客户范围
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url13") url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url13")
request_body = commonFuc().get_business_data(module, "payload13") request_body = commonFuc().get_business_data(module, "payload13", rebate_id)
# 发送请求 # 发送请求
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)
...@@ -35,7 +48,7 @@ customer_random = random.randint(0, len(result["data"]["list"]) - 1) ...@@ -35,7 +48,7 @@ customer_random = random.randint(0, len(result["data"]["list"]) - 1)
customer_name = result["data"]["list"][customer_random]["customername"] customer_name = result["data"]["list"][customer_random]["customername"]
customer_code = result["data"]["list"][customer_random]["customercode"] customer_code = result["data"]["list"][customer_random]["customercode"]
# 第步进行条件查询验证 # 第步进行条件查询验证
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url14") url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url14")
request_body = commonFuc().get_business_data(module, "payload14", customer_name, customer_code) request_body = commonFuc().get_business_data(module, "payload14", customer_name, customer_code)
""" """
......
...@@ -41,14 +41,14 @@ def func(x): ...@@ -41,14 +41,14 @@ def func(x):
# 生成一个随机数字,用于后续随机选择某一条返利使用明细 # 生成一个随机数字,用于后续随机选择某一条返利使用明细
rebate_random = random.randint(0, len(result["data"]["list"]) - 1) rebate_random = random.randint(1, len(result["data"]["list"]) - 1)
# 获取返利使用明细列表中某一条明细信息 # 获取返利使用明细列表中某一条明细信息
customer_code = result["data"]["list"][rebate_random]["customerCode"] customer_code = result["data"]["list"][rebate_random]["customerCode"]
customer_name = result["data"]["list"][rebate_random]["customerName"] customer_name = func(result["data"]["list"][rebate_random]["customerName"])
relevance_name = result["data"]["list"][rebate_random]["relevanceName"] relevance_name = result["data"]["list"][rebate_random]["relevanceName"]
transaction_type = result["data"]["list"][rebate_random]["transactionType"] transaction_type = result["data"]["list"][rebate_random]["transactionType"]
rebate_id = result["data"]["list"][rebate_random]["rebateId"] rebate_id = func(result["data"]["list"][rebate_random]["rebateId"])
rebate_name = result["data"]["list"][rebate_random]["rebateName"] rebate_name = func(result["data"]["list"][rebate_random]["rebateName"])
list_order_status = func(result["data"]["list"][rebate_random]["orderStatus"]) list_order_status = func(result["data"]["list"][rebate_random]["orderStatus"])
demand_code = func(result["data"]["list"][rebate_random]["demandCode"]) demand_code = func(result["data"]["list"][rebate_random]["demandCode"])
start_time = result["data"]["list"][rebate_random]["createTimeStr"] start_time = result["data"]["list"][rebate_random]["createTimeStr"]
...@@ -61,7 +61,7 @@ request_body = commonFuc().get_business_data(module, "payload2", customer_code, ...@@ -61,7 +61,7 @@ request_body = commonFuc().get_business_data(module, "payload2", customer_code,
transaction_type, transaction_type,
rebate_id, rebate_name, list_order_status, demand_code, start_time, rebate_id, rebate_name, list_order_status, demand_code, start_time,
end_time) end_time)
# print(request_body)
""" """
场景: 验证返利使用明细列表查询条件是否可以正常使用 场景: 验证返利使用明细列表查询条件是否可以正常使用
用例名称:列表查询条件验证_返利使用明细 用例名称:列表查询条件验证_返利使用明细
...@@ -72,9 +72,17 @@ request_body = commonFuc().get_business_data(module, "payload2", customer_code, ...@@ -72,9 +72,17 @@ request_body = commonFuc().get_business_data(module, "payload2", customer_code,
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)
print(result) print(result)
# 获取查询结果中使用明细对应的客户编号 if result["data"]["list"]:
result = {"customerCode": result["data"]["list"][0]["customerCode"]} # 获取查询结果中使用明细对应的客户编号
# 获取预期结果 result = {"customerCode": result["data"]["list"][0]["customerCode"]}
check_dict = commonFuc().get_business_data(module, "checkDict2", customer_code) # 获取预期结果
# 断言实际结果中是否包含预期结果的内容 check_dict = commonFuc().get_business_data(module, "checkDict2", customer_code)
commonFuc().check_result(check_dict, result) # 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
else:
# 获取查询结果中使用明细对应的客户编号
result = {"list": result["data"]["list"]}
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict2_1")
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
...@@ -31,7 +31,7 @@ result = json.loads(result.content) ...@@ -31,7 +31,7 @@ result = json.loads(result.content)
# 随机获取不相同两个商品信息 # 随机获取不相同两个商品信息
product_id_a = random.randint(1, len(result["data"]["list"]) - 2) product_id_a = random.randint(1, len(result["data"]["list"]) - 2)
product_a = result["data"]["list"][product_id_a] product_a = result["data"]["list"][product_id_a]
product_id_b = random.randint(product_id_a + 1, len(result["data"]["list"])) product_id_b = random.randint(product_id_a + 1, len(result["data"]["list"])-1)
product_b = result["data"]["list"][product_id_b] product_b = result["data"]["list"][product_id_b]
# 第二步进行新老商品关系编码维护新增 # 第二步进行新老商品关系编码维护新增
......
...@@ -35,6 +35,7 @@ checkDict1: {"success":true,"code":"200","message":"OK"} ...@@ -35,6 +35,7 @@ checkDict1: {"success":true,"code":"200","message":"OK"}
"payload2": {"terminalSign":1,"companyName":null,"customerCode":"%s","customerName":"%s","relevanceName":"%s","transactionType":"%s","relevanceCode":null,"rebateId":"%s","rebateName":"%s","listOrderStatus":["%s"],"demandCode":"%s","startTime":"%s","endTime":"%s","pageNum":1,"pageSize":10} "payload2": {"terminalSign":1,"companyName":null,"customerCode":"%s","customerName":"%s","relevanceName":"%s","transactionType":"%s","relevanceCode":null,"rebateId":"%s","rebateName":"%s","listOrderStatus":["%s"],"demandCode":"%s","startTime":"%s","endTime":"%s","pageNum":1,"pageSize":10}
#预期结果 #预期结果
checkDict2: {"customerCode":"%s"} checkDict2: {"customerCode":"%s"}
checkDict2_1: {"list":[]}
#测试场景三:返利规则获取验证 #测试场景三:返利规则获取验证
"url3": "/order/rebate/getList" "url3": "/order/rebate/getList"
......
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