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.
121 lines
6.0 KiB
121 lines
6.0 KiB
*** Settings ***
|
|
Library urllib3
|
|
Library String
|
|
Library demjson
|
|
Library DateTime
|
|
Library Collections
|
|
Library HttpLibrary
|
|
Library JSONLibrary
|
|
Library RequestsLibrary
|
|
Library DatabaseLibrary
|
|
Library HttpLibrary.HTTP
|
|
|
|
*** Keywords ***
|
|
查询${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}
|
|
END
|
|
#获取指定下标数据
|
|
${activityProductList} Create List
|
|
${indexs} Create List 0 1 2 3 4 6
|
|
FOR ${index} IN @{indexs}
|
|
${productData} Set Variable ${records[${index}]}
|
|
${subCategory} Get From Dictionary ${productData} subCategory
|
|
${Data} Add Object To Json ${productData} $.freebie true #将freebie:true塞到商品json中
|
|
Set Global Variable ${Data}
|
|
Run Keyword If ${subCategory}==601 更新是否赠品数据
|
|
... ELSE log ${Data}
|
|
Append To List ${activityProductList} ${Data}
|
|
Set Global Variable ${activityProductList}
|
|
END
|
|
#将'转换为"
|
|
${ActivityDataList} Create List
|
|
FOR ${data} IN @{activityProductList}
|
|
${freebie} Get From Dictionary ${data} freebie #是否时赠品
|
|
Set Global Variable ${data}
|
|
Run Keyword If '${freebie}'=='true' 设置赠品时商品价格为0
|
|
${data} Evaluate demjson.encode(${data},encoding='utf-8').decode() demjson
|
|
Append To List ${ActivityDataList} ${data}
|
|
END
|
|
${ActivityDataList} Convert To String ${ActivityDataList}
|
|
${ActivityDataList} Replace String Using Regexp ${ActivityDataList} '{ {
|
|
${ActivityDataList} Replace String Using Regexp ${ActivityDataList} }' }
|
|
log ${ActivityDataList}
|
|
Set Global Variable ${ActivityDataList}
|
|
|
|
更新是否赠品数据
|
|
${Data} Update Value To Json ${Data} $.freebie false
|
|
Set Global Variable ${Data}
|
|
log ${Data}
|
|
|
|
设置赠品时商品价格为0
|
|
${Data} Update Value To Json ${Data} $.unitSellingPrice 0
|
|
Set Global Variable ${Data}
|
|
log ${Data}
|
|
|
|
运营创建${dating}活动
|
|
#创建活动
|
|
FOR ${admin_header} IN @{Aheader_list}
|
|
Create Session dating ${${dating}.dating域名} ${admin_header}
|
|
${dateTime} Get Current Date result_format=%Y-%m-%d
|
|
${startTime} Get Current Date result_format=%Y-%m-%d 00:00:00
|
|
${endTime} Get Current Date ${startTime} 5 days
|
|
${data} Set Variable { \ \ \ \ "activityName":"会员测试活动", \ \ \ \ "startTime":"${startTime}", \ \ \ \ "endTime":"${endTime}", \ \ \ \ "remark":"创建测试活动${dateTime}", \ \ \ \ "activityProductList":${ActivityDataList} }
|
|
log ${data}
|
|
${reps} POST On Session dating dating-agency-mall/user/save/activity ${data.encode('utf-8')}
|
|
${id} Get From Dictionary ${reps.json()} data
|
|
${message} Get From Dictionary ${reps.json()} message
|
|
Should Be Equal As Strings ${message} successful
|
|
END
|
|
Set Global Variable ${id}
|
|
|
|
查询${dating}平台活动列表
|
|
#查询活动列表
|
|
FOR ${admin_header} IN @{Aheader_list}
|
|
Create Session dating ${${dating}.dating域名} ${admin_header}
|
|
${reps} GET On Session dating dating-agency-mall/user/get/activity/by/operator/page params=pageSize=10&pageNum=1
|
|
${activityData} Get From Dictionary ${reps.json()['data']} records
|
|
Set Global Variable ${activityData}
|
|
遍历活动列表
|
|
END
|
|
|
|
遍历活动列表
|
|
FOR ${activity} IN @{activityData}
|
|
${activityId} Get From Dictionary ${activity} id
|
|
Exit For Loop If ${activityId}==${id}
|
|
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}
|
|
END
|
|
#获取指定下标数据
|
|
${activityProductList} Create List
|
|
${indexs} Create List 0 1 2 3 4 6
|
|
FOR ${index} IN @{indexs}
|
|
${productData} Set Variable ${records[${index}]}
|
|
${subCategory} Get From Dictionary ${productData} subCategory
|
|
${Data} Add Object To Json ${productData} $.freebie true #将freebie:true塞到商品json中
|
|
${freebie} Get From Dictionary ${Data} freebie #是否时赠品
|
|
Set Global Variable ${Data}
|
|
Run Keyword If ${subCategory}==601 更新是否赠品数据
|
|
... ELSE log ${Data}
|
|
Run Keyword If '${freebie}'=='true' 设置赠品时商品价格为0
|
|
${Data} Evaluate demjson.encode(${Data},encoding='utf-8').decode() demjson #转换城字符串
|
|
Append To List ${activityProductList} ${Data}
|
|
log ${activityProductList}
|
|
Set Global Variable ${activityProductList}
|
|
END
|
|
${ActivityDataList} Convert To String ${activityProductList}
|
|
${ActivityDataList} Replace String Using Regexp ${ActivityDataList} '{ {
|
|
${ActivityDataList} Replace String Using Regexp ${ActivityDataList} }' }
|
|
log ${ActivityDataList}
|
|
Set Global Variable ${ActivityDataList}
|