diff --git "a/air_case/cmdc_product/\345\210\227\350\241\250\346\237\245\350\257\242\346\235\241\344\273\266\351\252\214\350\257\201_\345\217\221\350\264\247\346\227\266\351\227\264\345\210\227\350\241\250.air/\345\210\227\350\241\250\346\237\245\350\257\242\346\235\241\344\273\266\351\252\214\350\257\201_\345\217\221\350\264\247\346\227\266\351\227\264\345\210\227\350\241\250.py" "b/air_case/cmdc_product/\345\210\227\350\241\250\346\237\245\350\257\242\346\235\241\344\273\266\351\252\214\350\257\201_\345\217\221\350\264\247\346\227\266\351\227\264\345\210\227\350\241\250.air/\345\210\227\350\241\250\346\237\245\350\257\242\346\235\241\344\273\266\351\252\214\350\257\201_\345\217\221\350\264\247\346\227\266\351\227\264\345\210\227\350\241\250.py" new file mode 100644 index 0000000000000000000000000000000000000000..c4c278d96e144e4cd20f6633aded0b56fb7d6be0 --- /dev/null +++ "b/air_case/cmdc_product/\345\210\227\350\241\250\346\237\245\350\257\242\346\235\241\344\273\266\351\252\214\350\257\201_\345\217\221\350\264\247\346\227\266\351\227\264\345\210\227\350\241\250.air/\345\210\227\350\241\250\346\237\245\350\257\242\346\235\241\344\273\266\351\252\214\350\257\201_\345\217\221\350\264\247\346\227\266\351\227\264\345\210\227\350\241\250.py" @@ -0,0 +1,99 @@ +# -*- encoding=utf8 -*- +__author__ = "liguangyu" + +""" +case_tag:cmdc_api,cmdc列表查询条件验证_发货时间列表,2293,2293-035,sit,bs +主数据平台:运营后台管理系统发货时间列表接口 +""" + +from common.common_func import commonFuc +from air_case.cmdc_login.后台管理系统登录.后台管理系统登录 import CmdcDoLogin +import requests +import random +import json + +module = "cmdc_product" + +# 获取登录所需账号密码 +username = commonFuc().get_business_data(module, "username1") +password = commonFuc().get_business_data(module, "password1") +# 获取登录后Cmdc_access_token +cmdc_access_token = CmdcDoLogin(username, password).get_token() +headers = commonFuc().get_business_data(module, "json_headers", cmdc_access_token) + +# 获取发货时间列表 +url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url34") +request_body = commonFuc().get_business_data(module, "payload34") + +# 发送请求 +result = requests.get(url, params=request_body, headers=headers) +result = json.loads(result.content) + +# 生成一个随机数 +delivery_time_random = random.randint(0, len(result["data"]["list"]) - 1) +# 判断商品圈定方式 +if result["data"]["list"][delivery_time_random]["productRangeType"]: + + # 当商品圈定方式为按商品时,进行商品相关字段查询验证 + delivery_time_id = result["data"]["list"][delivery_time_random]["deliveryTimeId"] + # 通过查看发货时间详情获取商品信息 + url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url36") + request_body = commonFuc().get_business_data(module, "payload36", delivery_time_id) + + # 发送请求 + result1 = requests.get(url, params=request_body, headers=headers) + result1 = json.loads(result1.content) + + # 获取商品信息 + line_codes = "" + name = result1["data"]["list"][delivery_time_random]["name"] + status = result1["data"]["list"][delivery_time_random]["status"] + product_code = result1["data"]["list"][delivery_time_random]["productList"][0]["productCode"] + product_name = result1["data"]["list"][delivery_time_random]["productList"][0]["productName"] + + # 进行查询条件验证 + url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url35") + request_body = commonFuc().get_business_data(module, "payload35", line_codes, name, status, product_code, + product_name) + + # 发送请求 + result = requests.get(url, params=request_body, headers=headers) + result = json.loads(result.content) + # print(result) + # 获取查询结果中规则名称 + result = {"name": result["data"]["list"][0]["name"]} + # 获取预期结果 + check_dict = commonFuc().get_business_data(module, "checkDict35", name) + # print(check_dict) + # 断言实际结果中是否包含预期结果的内容 + commonFuc().check_result(check_dict, result) +else: + # 当商品圈定方式为按产品线时,进行产品线相关字段查询验证 + line_codes = result["data"]["list"][delivery_time_random]["lineCodes"] + name = result["data"]["list"][delivery_time_random]["name"] + status = result["data"]["list"][delivery_time_random]["status"] + product_code = "" + product_name = "" + + # 进行查询条件验证 + url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url35") + request_body = commonFuc().get_business_data(module, "payload35", line_codes, name, status, product_code, + product_name) + + """ + 场景: 列表查询条件验证_发货时间列表 + 用例名称:列表查询条件验证_发货时间列表 + 输出:{"name":"%s"} + """ + + # 发送请求 + result = requests.get(url, params=request_body, headers=headers) + result = json.loads(result.content) + # print(result) + # 获取查询结果中规则名称 + result = {"name": result["data"]["list"][0]["name"]} + # 获取预期结果 + check_dict = commonFuc().get_business_data(module, "checkDict35", name) + # print(check_dict) + # 断言实际结果中是否包含预期结果的内容 + commonFuc().check_result(check_dict, result) diff --git a/data/cmdc_product/data b/data/cmdc_product/data index 8e6854d84bc6721515331a7e456896cf08110c0c..92c380c2e06c86ffe872f79ce54e2ec66c499902 100644 --- a/data/cmdc_product/data +++ b/data/cmdc_product/data @@ -243,13 +243,25 @@ checkDict32: {"success":true,"code":"200","message":"OK","data":"success","fresh checkDict33: {"success":true,"code":"200","message":"OK","data":"success"} +#测试场景三十四:获取发货时间 +"url34": "/product/deliveryTime/list" +"payload34": {"companyCode":null,"lineCodes":null,"name":null,"status":null,"productCode":null,"productName":null,"pageStart":1,"pageSize":10} +#预期结果 +checkDict34: {"success":true,"code":"200","message":"OK"} +#测试场景三十五:列表查询条件验证_发货时间列表 +"url35": "/product/deliveryTime/list" +"payload35": {"companyCode":null,"lineCodes":"%s","name":"%s","status":"%s","productCode":"%s","productName":"%s","pageStart":1,"pageSize":10} +#预期结果 +checkDict35: {"name":"%s"} - - - +#测试场景三十六:查看发货时间详情 +"url36": "/product/deliveryTime/selectOne" +"payload36": {"id":"%s"} +#预期结果 +checkDict36: {"id":"%s"}