diff --git a/000-LoginToken/000-dataDriven.robot b/000-LoginToken/000-dataDriven.robot index c4cb936..197f99b 100644 --- a/000-LoginToken/000-dataDriven.robot +++ b/000-LoginToken/000-dataDriven.robot @@ -9,16 +9,28 @@ Library DatabaseLibrary LoginBase #印包管家登录基础数据 #域名 - ${uecFactory} Set Variable https://api-client-uec-test.qniao.cn #uec客户端域名 - ${yytFactory} Set Variable https://api-client-yyt-test.qniao.cn #yyt客户端域名 + ${uecClient} Set Variable https://api-client-uec-test.qniao.cn #uec客户端域名 + ${yytClient} Set Variable https://api-client-yyt-test.qniao.cn #yyt客户端域名 + ${uecFactory} Set Variable https://api-client-uec-test.qniao.cn #uec工厂端域名 + ${yytFactory} Set Variable https://api-client-yyt-test.qniao.cn #yyt工厂端域名 + Set Global Variable ${uecClient} + Set Global Variable ${yytClient} Set Global Variable ${uecFactory} Set Global Variable ${yytFactory} #登录Header - ${client-loginHeader} Set Variable {'Content-Type':'application/json','X-APP-ID':'503258978847966422'} #客户端登录Header - Set Global Variable ${client-loginHeader} + ${Client-LoginHeader} Set Variable {'Content-Type':'application/json','X-APP-ID':'503258978847966422'} #客户端登录Header + ${Factory-LoginHeader} Set Variable {'Content-Type':'application/json','X-APP-ID':'503258978847966422'} #工厂端登录Header + Set Global Variable ${Client-LoginHeader} + Set Global Variable ${Factory-LoginHeader} #登录账号 + ${New_account} Set Variable 12222222226 #新用户登录 ${client_account} Set Variable 15014242835 #客户端登录账号 + ${factory_account} Set Variable 15014242835 #工厂端登录账号 + Set Global Variable ${New_account} Set Global Variable ${client_account} + Set Global Variable ${factory_account} #登录密码 ${client_password} Set Variable 888888 #客户端登录密码 + ${factory_password} Set Variable 888888 #工厂端登录密码 + Set Global Variable ${client_password} Set Global Variable ${client_password} diff --git a/000-LoginToken/Client-Login.robot b/000-LoginToken/Client-Login.robot index dfeb1b3..27041a6 100644 --- a/000-LoginToken/Client-Login.robot +++ b/000-LoginToken/Client-Login.robot @@ -3,13 +3,20 @@ Documentation 客户端登录 Library urllib3 Library Collections Library RequestsLibrary +Library DatabaseLibrary *** Test Cases *** +NewLogin + #新用户登录 + Create Session factory ${uecClient} ${Client-LoginHeader} + ${data} Set Variable {"authCode":"0f3wAd0w3dASy13Mkk2w3q8rqC2wAd0P","authMethod":"WeChatMiniProgram"} #拉取微信 + ${reps} POST On Session factory uec/authorize/by-oauth2 data=${data} + uec-login #登录uec - #账号密码登录 + #普通用户账号密码登录 Disable Warnings - Create Session factory ${uecFactory} ${client-loginHeader} + Create Session factory ${uecClient} ${Client-LoginHeader} ${LoginData} Set Variable {"account":"${client_account}","captcha":"${client_password}","accountType":2} ${resp} POST On Session factory uec/authorize/by-captcha data=${LoginData} ${token} Get From Dictionary ${resp.json()["data"]} token #获取UECtoken @@ -19,7 +26,7 @@ uec-login Login-token #切换业务线token - Create Session factory ${yytFactory} ${client-loginHeader} + Create Session factory ${yytClient} ${Client-LoginHeader} #${Token} Create Dictionary loginToken=${token} ${Token} Set Variable {"loginToken":"${token}"} ${reps} POST On Session factory yyt-uec/authorize/get/product-line-token/by/login-token ${Token.encode('utf-8')} @@ -30,8 +37,9 @@ Login-token BaseInfo #获取用户基础信息 - Create Session factory ${yytFactory} ${client_firstlogin_header} + Create Session factory ${yytClient} ${client_firstlogin_header} ${reps} GET On Session factory yyt-uec/get/base-info params=userId=${userId} + ${mobile} Get From Dictionary ${reps.json()["data"]} mobile #获取用户手机号 ${organizationList} Get From Dictionary ${reps.json()["data"]} organizationList #获取用户组织列表 FOR ${OrgList} IN @{organizationList} ${factoryList} Get From Dictionary ${OrgList} factoryList #获取工厂列表 @@ -45,8 +53,35 @@ BaseInfo Exit For Loop If '${Fid}'=='546450842056790018' #546450842056790018普睿特工厂id END ${ClientHeader} Set Variable {'Content-Type':'application/json','Authorization':'QNT ${Token}','X-APP-ID':'503258978847966422','X-FACTORY-ID':'${Fid}','X-ORGANIZATION-ID':'${organizationId}','X-PACKAGING-SERVICE-PROVIDER-ID':'${serviceProviderId}'} #获取组织信息的Header + #Run Keyword If '${mobile}'==null Run Keyword getPhone Set Global Variable ${Fid} Set Global Variable ${ClientHeader} Set Global Variable ${enterpriseId} Set Global Variable ${organizationId} Set Global Variable ${serviceProviderId} + +*** Keywords *** +UecLogin + Disable Warnings + Create Session factory ${uecClient} ${Client-LoginHeader} + ${LoginData} Set Variable {"account":"${client_account}","captcha":"${client_password}","accountType":2} + ${resp} POST On Session factory uec/authorize/by-captcha data=${LoginData} + ${token} Get From Dictionary ${resp.json()["data"]} token #获取UECtoken + ${userId} Get From Dictionary ${resp.json()["data"]} userId #获取用户id + Set Global Variable ${token} + Set Global Variable ${userId} + +LoginToken + #切换业务线token + Create Session factory ${yytClient} ${Client-LoginHeader} + #${Token} Create Dictionary loginToken=${token} + ${Token} Set Variable {"loginToken":"${token}"} + ${reps} POST On Session factory yyt-uec/authorize/get/product-line-token/by/login-token ${Token.encode('utf-8')} + ${Token} Get From Dictionary ${reps.json()} data #获取业务线token + #Set Global Variable ${Token} + ${client_firstlogin_header} Set Variable {'Content-Type':'application/json','Authorization':'QNT ${Token}','X-APP-ID':'503258978847966422'} #移动端首次登录headerBaseInfo + Set Global Variable ${client_firstlogin_header} + +getPhone + [Documentation] 无手机号获取手机号 + # diff --git a/000-LoginToken/Factory-Login.robot b/000-LoginToken/Factory-Login.robot index 5a3eb0d..6a111a5 100644 --- a/000-LoginToken/Factory-Login.robot +++ b/000-LoginToken/Factory-Login.robot @@ -5,3 +5,8 @@ Library Collections Library RequestsLibrary *** Test Cases *** +UECLogin + #UEC登录 + #工厂员工账号密码 + Create Session factory ${uecFactory} ${client-loginHeader} + ${Information} Set Variable {"account":"${client_account}","captcha":"${client_password}","accountType":2} diff --git a/001-Coupon/Coupon.robot b/001-Coupon/Coupon.robot new file mode 100644 index 0000000..9a82c26 --- /dev/null +++ b/001-Coupon/Coupon.robot @@ -0,0 +1,123 @@ +*** Settings *** +Documentation 优惠券 +Library urllib3 +Library Collections +Library RequestsLibrary +Library DatabaseLibrary + +*** Test Cases *** +0-register + #注册登录送券 + Run Keyword UecLogin + Run Keyword LoginToken + Create Session factory ${uecClient} ${client_firstlogin_header} + ${reps} GET On Session factory coupon-service/user/page/coupon params=checked=false + ${records} Get From Dictionary ${reps.json()['data']} records #获取优惠券列表 + Run Keyword DeleteLogin + +OrderCoupon + #下首单送券 + Run Keyword UecLogin + Run Keyword LoginToken + Run Keyword BaseInfo + Run Keyword 完善用户信息 + #获取spu列表 + Create Session factory ${yytClient} ${client_firstlogin_header} + ${reps} GET On Session factory printing-packaging-factory-service/user/get/all-spu-list params=printingType=2&status=1 + ${records} Get From Dictionary ${reps.json()['data']} records + FOR ${Items} IN @{records} + ${id} Get From Dictionary ${Items} id #获取spuid + ${name} Get From Dictionary ${Items} name #盒子名称 + ${orgId} Get From Dictionary ${Items} orgId #获取spuorgid + ${factoryId} Get From Dictionary ${Items} factoryId #获取spufactoryId + Exit For Loop If '${id}'=='820801091557003264' #下单内托 + END + #获取SPU报价 + ${spuData} Set Variable {"spuId":"${id}","basic":true} + ${reps} POST On Session factory printing-packaging-factory-service/user/render/spu-detail data=${spuData.encode('utf-8')} + ${desc} Get From Dictionary ${reps.json()['data']['quote']} desc #盒型参数 + ${count} Get From Dictionary ${reps.json()['data']['quote']} count #下单数量 + ${price} Get From Dictionary ${reps.json()['data']['quote']} price #单价 + ${quote} Get From Dictionary ${reps.json()['data']} quote #获取报价json + ${amount} Get From Dictionary ${reps.json()['data']['quote']} amount #获取盒型价格 + ${spuDetail} Get From Dictionary ${reps.json()['data']} spuDetail #获取盒型渲染 + ${processDesc} Get From Dictionary ${reps.json()['data']['quote']} processDesc #盒型工艺 + ${productArea} Get From Dictionary ${reps.json()['data']['quote']} productArea #初始化尺寸 + ${materialDesc} Get From Dictionary ${reps.json()['data']['quote']} materialDesc #盒型材质 + ${originalAmount} Get From Dictionary ${reps.json()['data']['quote']} originalAmount #低消 + ${productMeasureDesc} Get From Dictionary ${reps.json()['data']['quote']} productMeasureDesc #下单尺寸 + ${productProcessDesc} Get From Dictionary ${reps.json()['data']['quote']} productProcessDesc #下单工艺 + ${productMaterialDesc} Get From Dictionary ${reps.json()['data']['quote']} productMaterialDesc #下单材质 + ${data} Get From Dictionary ${reps.json()} data + #${productSpecDetailJson} Set Variable {"quote":"${quote}"} + #获取工厂税点信息(自提) + #${reps} GET On Session factory printing-package-mall-service/user/page/invoice-title params=pageNum=factoryId=${factoryId}&orgId=${orgId}&deliveryAddressProvinceId=&deliveryAddressCityId=&deliveryAddressDistrictId= + #${enterpriseInvoiceList} Get From Dictionary ${reps.json()['data']} enterpriseInvoiceList + #FOR ${Freedata} IN @{enterpriseInvoiceList} + #${tax} Get From Dictionary ${Freedata} tax #税点 + #${type} Get From Dictionary ${Freedata} type #开票类型 + #${logisticsCharges} Get From Dictionary ${Freedata} logisticsCharges #物流费用 + #Exit For Loop If '${type}'==1 #普通发票:1,专用发票:2 + #END + #获取用户钱包账号 + Create Session factory ${uecClient} ${client_firstlogin_header} + ${reps} GET On Session factory wallet-service/user/get/wallet-account + ${amountGift} Get From Dictionary ${reps.json()['data']} amountGift #赠送金额 + ${totalBalance} Get From Dictionary ${reps.json()['data']} totalBalance #总金额 + ${frozenBalance} Get From Dictionary ${reps.json()['data']} frozenBalance #可用金额 + ${availableBalance} Get From Dictionary ${reps.json()['data']} availableBalance #冻结金额 + #获取可用优惠券 + #${reps} GET On Session factory coupon-service/user/calculate/discount-amount params=amount=${amount}&couponBusinessType=2&isUseCoupon=true + #创建订单 + Create Session factory ${yytClient} ${client_firstlogin_header} + ${OrderData} Set Variable { \ \ \ \ "remark":"", \ \ \ \ "totalAmount":"${amount}", \ \ \ \ "taxFee":0, \ \ \ \ "taxRate":0, \ \ \ \ "logisticsFee":0, \ \ \ \ "supplierFactoryId":"${factoryId}", \ \ \ \ "supplierOrgId":"${orgId}", \ \ \ \ "customerContactsName":"26用户", \ \ \ \ "customerContactsPhone":"${mobile}", \ \ \ \ "packingMethod":2, \ \ \ \ "salesOrderInvoice":{ \ \ \ \ \ \ \ \ "type":0 \ \ \ \ }, \ \ \ \ "salesOrderItemProduct":{ \ \ \ \ \ \ \ \ "productName":"${name}", \ \ \ \ \ \ \ \ "productId":"${id}", \ \ \ \ \ \ \ \ "amount":"${amount}", \ \ \ \ \ \ \ \ "quantity":"${count}", \ \ \ \ \ \ \ \ "price":"${price}", \ \ \ \ \ \ \ \ "productImgUrl":"https://qncloudprintfiletest.oss-cn-shenzhen.aliyuncs.com/cloudprint/ee9ecad4-9535-42af-b92f-f7d5c804df1c.png", \ \ \ \ \ \ \ \ "factoryId":"${factoryId}", \ \ \ \ \ \ \ \ "orgId":"${orgId}", \ \ \ \ \ \ \ \ "orderSource":1, \ \ \ \ \ \ \ \ "desc":"${desc}", \ \ \ \ \ \ \ \ "productMeasureDesc":"${productMeasureDesc}", \ \ \ \ \ \ \ \ "productMaterialDesc":"${productMaterialDesc}", \ \ \ \ \ \ \ \ "productProcessDesc":"${productProcessDesc}", \ \ \ \ \ \ \ \ "copyFromId":null, \ \ \ \ \ \ \ \ "productSpecDetailJson":{"quote":"${data}"}, \ \ \ \ \ \ \ \ "productSpecDetail":"${desc}" \ \ \ \ }, \ \ \ \ "orderSource":1 } + ${reps} POST On Session factory printing-package-mall-service/user/create/sales-order data=${OrderData.encode('utf-8')} + ${OrderId} Get From Dictionary ${reps.json()} data #获取订单id + +*** Keywords *** +DeleteLogin + #新用户登录 + #判断新用户 + Connect To Database Using Custom Params pymysql host='8.135.8.221',user='root', password='qniaothreetwoonego', \ port=3306,database='ztb_recycle' #链接测试环境数据库 + Execute Sql String UPDATE `uec`.`qn_account` SET `is_delete` = 1 WHERE `user_id` = ${userId}; + Execute Sql String UPDATE `uec`.`qn_user` SET `is_delete` = 1 WHERE `id` = ${userId}; + Execute Sql String UPDATE `coupon`.`qn_user_behavior` SET `is_delete` = 1 WHERE `user_id` = ${userId} + Disconnect From Database + Sleep 1 + +UecLogin + #登录UEC + Disable Warnings + Create Session factory ${uecClient} ${Client-LoginHeader} + ${LoginData} Set Variable {"account":"${New_account}","captcha":"${client_password}","accountType":2} + ${resp} POST On Session factory uec/authorize/by-captcha data=${LoginData} + ${token} Get From Dictionary ${resp.json()["data"]} token #获取UECtoken + ${userId} Get From Dictionary ${resp.json()["data"]} userId #获取用户id + Set Global Variable ${token} + Set Global Variable ${userId} + +LoginToken + #切换业务线token + Create Session factory ${yytClient} ${Client-LoginHeader} + #${Token} Create Dictionary loginToken=${token} + ${Token} Set Variable {"loginToken":"${token}"} + ${reps} POST On Session factory yyt-uec/authorize/get/product-line-token/by/login-token ${Token.encode('utf-8')} + ${Token} Get From Dictionary ${reps.json()} data #获取业务线token + #Set Global Variable ${Token} + ${client_firstlogin_header} Set Variable {'Content-Type':'application/json','Authorization':'QNT ${Token}','X-APP-ID':'503258978847966422'} #移动端首次登录headerBaseInfo + Set Global Variable ${client_firstlogin_header} + +BaseInfo + #获取用户基础信息 + Create Session factory ${yytClient} ${client_firstlogin_header} + ${reps} GET On Session factory yyt-uec/get/base-info params=userId=${userId} + ${mobile} Get From Dictionary ${reps.json()["data"]} mobile #获取用户手机号 + Set Global Variable ${mobile} + +完善用户信息 + #完善用户信息 + Create Session factoey ${uecClient} ${client_firstlogin_header} + ${UserData} Set Variable {"avatar":"https://qncloudprintfiletest.oss-cn-shenzhen.aliyuncs.com/cloudprint/1697687519017.jpeg","nickname":"26用户"} + ${reps} POST On Session factoey uec/user/update/user-info params=userId=${userId} data=${UserData.encode('utf-8')} + ${message} Get From Dictionary ${reps.json()} message + Should Be Equal ${message} successful diff --git a/001-Coupon/__init__.robot b/001-Coupon/__init__.robot new file mode 100644 index 0000000..e69de29 diff --git a/002-SpuCalculation/Calculation.robot b/002-SpuCalculation/Calculation.robot new file mode 100644 index 0000000..9906d4e --- /dev/null +++ b/002-SpuCalculation/Calculation.robot @@ -0,0 +1,26 @@ +*** Settings *** +Library urllib3 +Library Collections +Library RequestsLibrary +Library DatabaseLibrary + +*** Test Cases *** +spu + #尺寸换算 + #获取盒型大类 + Create Session factory ${yytClient} ${ClientHeader} + ${reps} GET On Session factory printing-packaging-factory-service/user/page/spu-category-by params=enable=true&parentId=1&existFormula=true + ${records} Get From Dictionary ${reps.json()['data']} records #盒型大类列表 + ${Json} Evaluate random.choice(${records}) random #获取随机盒型 + ${SpuCategoryId} Get From Dictionary ${Json} id #盒型大类id + ${SpuCategoryName} Get From Dictionary ${Json} name #盒型大类名称 + #获取盒型分类数据 + ${reps} GET On Session factory printing-packaging-factory-service/user/page/spu-category-by params=enable=true&parentId=${SpuCategoryId}&level=3&existFormula=true + ${records} Get From Dictionary ${reps.json()['data']} records #获取盒型分类列表 + FOR ${items} IN @{records} + ${id} Get From Dictionary ${items} id #盒型分类id + ${name} Get From Dictionary ${items} name #盒型分类name + Exit For Loop If '${name}'=='双插盒' + END + #盒型分类详情 + ${reps} GET On Session \ printing-packaging-factory-service/user/get/spu-category-unfolding-size-calculation-detail/796099526745264128 diff --git a/002-SpuCalculation/__init__.robot b/002-SpuCalculation/__init__.robot new file mode 100644 index 0000000..cf81588 --- /dev/null +++ b/002-SpuCalculation/__init__.robot @@ -0,0 +1,2 @@ +*** Settings *** +Documentation 盒型尺寸换算