*** Settings *** Documentation 创建常规订单 Test Teardown Run Keyword If Test Failed Fatal Error Test Timeout Library RequestsLibrary Library Collections Library DateTime Library urllib3 Library String *** Variables *** ${header} {'content-type':'application/json','X-APP-ID':'470236309865238528','Authorization':'QNT ${gettoken}'} ${url} https://api-client-ztb-test.qniao.cn *** Test Cases *** get_paper-mill-city #获取纸厂所在城市 Create Session ZTBT ${url} ${header} ${reps} Get On Session ZTBT recycle-service/get/paper-mill-city ${data} Get From Dictionary ${reps.json()} data #城市列表 FOR ${items} IN @{data} ${cityName} Get From Dictionary ${items} cityName #城市name ${cityId} Get From Dictionary ${items} cityId #城市id Exit For Loop If '${cityName}'=='茂名市' END Set Global Variable ${cityId} get-factorylist #获取代卖列表 #${header} Create Dictionary content-type=application/json X-APP-ID=470236309865238528 Authorization=${gettoken} Create Session factorylist http://api-client-ztb-test.qniao.cn ${header} ${reps} Get On Session factorylist recycle-service/get/paper-mill-paper-category-price-list params=cityId=${cityId}&enableSalesAgent=1&pageNum=1&pageSize=20&listType=0 Should Be Equal As Strings ${reps.json()["message"]} successful ${records} Get From Dictionary ${reps.json()["data"]} records #获取代卖纸厂列表 FOR ${item} IN @{records} ${name} Get From Dictionary ${item} name #获取纸厂name ${paperCategoryList} Get From Dictionary ${item} paperCategoryList #获取纸厂品类列表 ${cumulativeWeight} Get From Dictionary ${item} cumulativeWeight #累计已代卖吨数 ${paperMillId} Get From Dictionary ${item} paperMillId #获取纸厂id ${locProvinceName} Get From Dictionary ${item} locProvinceName #纸厂所在省 ${locCityName} Get From Dictionary ${item} locCityName #纸厂所在市 ${locDistrictName} Get From Dictionary ${item} locDistrictName #纸厂所在区 Exit For Loop If '${name}'=='高州市金墩纸业有限公司' END ${value} Evaluate random.choice(${paperCategoryList}) random log to console \nvalue: ${value} ${categoryid} Get From Dictionary ${value} categoryId #纸厂品类id ${categoryName} Get From Dictionary ${value} categoryName #纸厂品类name ${unitPrice} Get From Dictionary ${value} unitPrice #纸厂品类价格 ${paperMillAddress} Catenate ${locProvinceName} ${locCityName} ${locDistrictName} Set Global Variable ${categoryid} Set Global Variable ${unitPrice} Set Global Variable ${paperMillId} Set Global Variable ${paperMillAddress} Set Global Variable ${categoryName} Set Global Variable ${name} paper-mill-paper-category-price-details #获取纸厂详情信息 Create Session ZTBT ${url} ${header} ${reps} Get On Session ZTBT recycle-service/get/paper-mill-paper-category-price-details/${paperMillId} log ${reps.json()} relation #获取业务邀请码弹窗 Create Session ZTBT ${url} ${header} ${reps} get On Session ZTBT recycle-service/proxy-sell/get/relation log ${reps,json()} relation_code #填写业务人员邀请码 Create Session ZTBT ${url} ${header} ${data} Set Variable {"code":"9999"} ${reps} Post On Session ZTBT recycle-service/proxy-sell/bind/relation ${data.encode('utf-8')} log ${reps.json()} get-carinfo #获取使用过的车辆信息 #${header} Create Dictionary content-type=application/json X-APP-ID=470236309865238528 Authorization=${gettoken} Create Session get-carinfo http://api-client-ztb-test.qniao.cn ${header} ${reps} Get On Session get-carinfo recycle-service/proxy-sell/get/his-car-info log ${reps.json()} ${carNumber} Get From Dictionary ${reps.json()["data"]} records #获取车辆列表 ${plateNumber1} Evaluate random.choice(${carNumber}) random log to console \nvalue:${plateNumber1} ${plateNumber} Get From Dictionary ${plateNumber1} plateNumber #车辆信息 Set Global Variable ${plateNumber} choose-factory #选择纸厂 ${header} Create Dictionary content-type=application/json X-APP-ID=470236309865238528 Authorization=${gettoken} Create Session choose-factory https://api-client-ztb-test.qniao.cn ${header} ${reps} Get On Session choose-factory recycle-service/get/paper-mill-paper-category-price-details/612629674392162304 log ${reps.json()["data"]} Should Be Equal As Strings ${reps.json()["message"]} successful save_factory-by-shipment-info #填写发货信息 #${headers} Create Dictionary content-type=application/json X-APP-ID=470236309865238528 Authorization=QNT d6SX3ESr8Jb2tYq/89Ft7ONlmJEiWUarjlNpFfW2lU9rgLvV1vzRLbb1Y4C5/b3g/PxwWTrvGmZUIarJEaEOkQ== Disable Warnings ${datatime} Get Current Date result_format=%Y-%m-%d Create Session ZTBT https://api-client-ztb-test.qniao.cn ${header} ${data} Set Variable {"packageFactoryName":"${datatime}打包站"} ${reps} Post On Session ZTBT recycle-user-center/save/factory-by-shipment-info ${data.encode('utf-8')} log ${reps.json()} Should Be Equal As Strings ${reps.json()["message"]} successful createorder #创建下单 #${header} Create Dictionary content-type=application/json X-APP-ID=470236309865238528 Authorization=QNT ${gettoken} ${datatime} get current date result_format=%Y-%m-%d #${DT} Add Time To Date ${datatime} -1 day #${str} Get Substring ${DT} 0 10 log ${datatime} ${data} Set Variable {"paperCategoryId":"${categoryid}" ,"unitPrice":${unitPrice},"totalEstimatedWeight":30000,"customerName":"赖勇兰","deliveryTime":"${datatime}","carInfos":[{"plateNumber":"${plateNumber}"}]} log ${data} Create Session createorder http://api-client-ztb-test.qniao.cn ${header} ${reps} Post On Session createorder recycle-service/proxy-sell/create/order ${data.encode('utf-8')} ${orderId} Get From Dictionary ${reps.json()["data"]} orderId #获取订单编号 log ${reps.json()} Should Be Equal As Strings ${reps.json()["message"]} successful Set Global Variable ${datatime} Set Global Variable ${orderId} createorder-newcar #创建下单(填写车辆信息) #${header} Create Dictionary content-type=application/json X-APP-ID=470236309865238528 Authorization=QNT ${gettoken} ${datatime} get current date result_format=%Y-%m-%d log ${datatime} ${data} Set Variable {"paperCategoryId":"${categoryid}" ,"unitPrice":${unitPrice},"totalEstimatedWeight":30000,"customerName":"赖勇兰","deliveryTime":"${datatime}","carInfos":[{"plateNumber":"宁G54321"}]} log ${data} Create Session createorder http://api-client-ztb-test.qniao.cn ${header} ${reps} Post On Session createorder recycle-service/proxy-sell/create/order ${data.encode('utf-8')} ${orderId} Get From Dictionary ${reps.json()["data"]} orderId #获取订单编号 log ${reps.json()} Should Be Equal As Strings ${reps.json()["message"]} successful Set Global Variable ${datatime} Set Global Variable ${orderId} Repeat Repeat Keyword 10 get-factorylist *** Keywords *** get-factorylist #获取代卖列表 #${header} Create Dictionary content-type=application/json X-APP-ID=470236309865238528 Authorization=${gettoken} Create Session factorylist http://api-client-ztb-test.qniao.cn ${header} ${reps} Get On Session factorylist recycle-service/get/paper-mill-paper-category-price-list params=cityId=&enableSalesAgent=1&pageNum=1&pageSize=10&listType=0 Should Be Equal As Strings ${reps.json()["message"]} successful ${records} Get From Dictionary ${reps.json()["data"]} records #获取代卖纸厂列表 FOR ${item} IN @{records} ${name} Get From Dictionary ${item} name #获取纸厂name ${paperCategoryList} Get From Dictionary ${item} paperCategoryList #获取纸厂品类列表 ${cumulativeWeight} Get From Dictionary ${item} cumulativeWeight #累计已代卖吨数 ${paperMillId} Get From Dictionary ${item} paperMillId #获取纸厂id ${locProvinceName} Get From Dictionary ${item} locProvinceName #纸厂所在省 ${locCityName} Get From Dictionary ${item} locCityName #纸厂所在市 ${locDistrictName} Get From Dictionary ${item} locDistrictName #纸厂所在区 Exit For Loop If '${name}'=='格森纸业有限公司' END ${value} Evaluate random.choice(${paperCategoryList}) random log to console \nvalue: ${value} ${categoryid} Get From Dictionary ${value} categoryId #纸厂品类id ${categoryName} Get From Dictionary ${value} categoryName #纸厂品类name ${unitPrice} Get From Dictionary ${value} unitPrice #纸厂品类价格 ${paperMillAddress} Catenate ${locProvinceName} ${locCityName} ${locDistrictName} Set Global Variable ${categoryid} Set Global Variable ${unitPrice} Set Global Variable ${paperMillId} Set Global Variable ${paperMillAddress} Set Global Variable ${categoryName}