You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
127 lines
8.4 KiB
127 lines
8.4 KiB
*** Settings ***
|
|
Library urllib3
|
|
Library String
|
|
Library Collections
|
|
Library RequestsLibrary
|
|
Library DatabaseLibrary
|
|
|
|
*** Keywords ***
|
|
平台商品数据创建
|
|
${productType_list} Create List 2 2 2 2 2 2 2 2 3
|
|
${subCategory_list} Create List 101 201 302 401 501 601 701 801 88801 #产品名称
|
|
${mainCategory_list} Create List 1 2 3 4 5 6 3 3 888 #产品分类
|
|
${productTitle_list} Create List 学历认证 头像修改 高级搜索 线下约见面 聊天卡 会员 包恋爱 包领证 红娘合伙人
|
|
${data_list} Create List
|
|
FOR ${mainCategory} ${subCategory} ${productTitle} ${productType} IN ZIP ${mainCategory_list} ${subCategory_list} ${productTitle_list} ${productType_list}
|
|
${productSpecUnit_list} Create List 101 102 #产品规格:101 周期,102 天数
|
|
${purchaseTimeValue} Evaluate random.randint(1,50) random #随机获取次数数量
|
|
${unitOriginalPrice} Evaluate random.randint(99,3999) random #随机获取商品原价
|
|
${unitSellingPrice} Evaluate ${unitOriginalPrice}/1000 #计算商品现价
|
|
${productSpecUnit} Evaluate random.choice(${productSpecUnit_list}) random #随机获取产品规格
|
|
${validityPeriodValue} Evaluate random.randint(30,365) random #随机获取有效周期天数
|
|
${data} Set Variable If ${productSpecUnit}==102 { \ \ \ \ "mainCategory": ${mainCategory}, \ \ \ \ "subCategory": ${subCategory}, \ \ \ \ "productTitle": "${productTitle}", \ \ \ \ "productDesc": "${productTitle}产品描述", \ \ \ \ "productSpecUnit": ${productSpecUnit}, \ \ \ \ "validityPeriodValue": ${validityPeriodValue}, \ \ \ \ "unitOriginalPrice": ${unitOriginalPrice}, \ \ \ \ "unitSellingPrice": ${unitSellingPrice}, \ \ \ \ "detailDesc": "${productTitle}详细描述", \ \ \ \ "purchaseTimeValue": ${purchaseTimeValue}, \ \ \ \ "productType": ${productType} } { \ \ \ \ "mainCategory": ${mainCategory}, \ \ \ \ "subCategory": ${subCategory}, \ \ \ \ "productTitle": "${productTitle}", \ \ \ \ "productDesc": "${productTitle}产品描述", \ \ \ \ "detailDesc": "${productTitle}详情描述", \ \ \ \ "unitOriginalPrice": ${unitOriginalPrice}, \ \ \ \ "unitSellingPrice": ${unitSellingPrice}, \ \ \ \ "productSpecUnit": ${productSpecUnit}, \ \ \ \ "validityPeriodValue": ${validityPeriodValue}, \ \ \ \ "purchaseTimeValue": "${purchaseTimeValue}", \ \ \ \ "productType": ${productType} }
|
|
Append To List ${data_list} ${data}
|
|
Set Global Variable ${data_list}
|
|
log ${data_list}
|
|
END
|
|
|
|
创建${dating}平台商品
|
|
#创建商品信息
|
|
FOR ${admin_header} IN @{Aheader_list}
|
|
Create Session dating ${${dating}.dating域名} ${admin_header}
|
|
${reps} POST On Session dating dating-agency-mall/user/create/product ${data.encode('utf-8')}
|
|
${productId} Get From Dictionary ${reps.json()} data #产品id
|
|
${message} Get From Dictionary ${reps.json()} message
|
|
Should Be Equal As Strings ${message} successful
|
|
Set Global Variable ${productId}
|
|
END
|
|
|
|
同时创建多个商品
|
|
${index} Set Variable -1
|
|
FOR ${data} IN @{data_list}
|
|
${index} Evaluate ${index}+1
|
|
Set Global Variable ${data}
|
|
创建婚介平台商品
|
|
END
|
|
|
|
查询${dating}平台商品定价列表
|
|
#查询商品列表
|
|
FOR ${admin_header} IN @{Aheader_list}
|
|
Create Session dating ${${dating}.dating域名} ${admin_header}
|
|
${reps} GET On Session dating dating-agency-mall/user/page/product/by/operator params=pageSize=10&pageNum=1
|
|
${records} Get From Dictionary ${reps.json()['data']} records #获取商品列表数据
|
|
Set Global Variable ${records}
|
|
#${product} Evaluate random.choice(${records}) random #随机获取商品信息
|
|
遍历商品列表
|
|
END
|
|
|
|
遍历商品列表
|
|
${statusList} Create List
|
|
${productIdList} Create List
|
|
${productTitleList} Create List
|
|
FOR ${product} IN @{records}
|
|
${status} Get From Dictionary ${product} status #商品状态
|
|
${productId} Get From Dictionary ${product} productId #商品id
|
|
${productTitle} Get From Dictionary ${product} productTitle #商品标题
|
|
${productSpecId} Get From Dictionary ${product} productSpecId #商品规格id
|
|
Append To List ${statusList} ${status}
|
|
Append To List ${productIdList} ${productId}
|
|
Append To List ${productTitleList} ${productTitle}
|
|
Set Global Variable ${status}
|
|
Set Global Variable ${productId}
|
|
Set Global Variable ${statusList}
|
|
Set Global Variable ${productTitle}
|
|
Set Global Variable ${productIdList}
|
|
Set Global Variable ${productSpecId}
|
|
Set Global Variable ${productTitleList}
|
|
END
|
|
|
|
数据库查询商品表
|
|
FOR ${productId} ${productTitle} IN ZIP ${productIdList} ${productTitleList}
|
|
Connect To Database Using Custom Params pymysql database='dating_agency_mall',user='root',password='qniaothreetwoonego',host='8.135.8.221'
|
|
${check} Query SELECT product_title FROM `dating_agency_mall`.`da_product` WHERE `id` = '${productId}' AND `is_delete` = '0' #通过商品id查询商品名称
|
|
${title} Set Variable ${check[0][0]}
|
|
Should Be Equal As Strings ${title} ${productTitle}
|
|
Disconnect From Database
|
|
END
|
|
|
|
操作${dating}平台商品上下架
|
|
#操作上架
|
|
FOR ${admin_header} IN @{Aheader_list}
|
|
Create Session dating ${${dating}.dating域名} ${admin_header}
|
|
批量上下架商品
|
|
END
|
|
|
|
批量上下架商品
|
|
FOR ${productId} ${status} IN ZIP ${productIdList} ${statusList}
|
|
${data} Set Variable If ${status}==2 {"productId":"${productId}","status":1} {"productId":"${productId}","status":2}
|
|
${reps} POST On Session dating dating-agency-mall/user/operate/product ${data.encode('utf-8')}
|
|
${message} Get From Dictionary ${reps.json()} message
|
|
Should Be Equal As Strings ${message} successful
|
|
END
|
|
|
|
条件查询${dating}平台商品
|
|
#产品名称查询商品
|
|
${subCategory_list} Create List 101 201 301 302 401 501 601 #产品名称
|
|
${subCategoryCode} Evaluate random.choice(${subCategory_list}) random #随机获取产品名称枚举
|
|
FOR ${admin_header} IN @{Aheader_list}
|
|
Create Session dating ${${dating}.dating域名} ${admin_header}
|
|
${reps} GET On Session dating dating-agency-mall/user/page/product/by/operator params=pageSize=10&subCategory=${subCategoryCode}&pageNum=1
|
|
${records} Get From Dictionary ${reps.json()['data']} records #查询后的商品列表
|
|
${productData} Evaluate random.choice(${records}) random
|
|
${subCategory} Get From Dictionary ${productData} subCategory #商品名称枚举
|
|
${subCategory} Convert To String ${subCategory}
|
|
Should Be Equal ${subCategory} ${subCategoryCode} #断言
|
|
END
|
|
#产品分类查询商品
|
|
${mainCategory_list} Create List 1 2 3 4 #产品分类
|
|
${mainCategoryCode} Evaluate random.choice(${mainCategory_list}) random #随机获取产品名称枚举
|
|
FOR ${admin_header} IN @{Aheader_list}
|
|
Create Session dating ${${dating}.dating域名} ${admin_header}
|
|
${reps} GET On Session dating dating-agency-mall/user/page/product/by/operator params=pageSize=10&mainCategory=${mainCategoryCode}&pageNum=1
|
|
${records} Get From Dictionary ${reps.json()['data']} records #查询后的商品列表
|
|
${productData} Evaluate random.choice(${records}) random
|
|
${mainCategory} Get From Dictionary ${productData} mainCategory #商品名称枚举
|
|
${mainCategory} Convert To String ${mainCategory}
|
|
Should Be Equal As Strings ${mainCategory} ${mainCategoryCode} #断言
|
|
END
|