feat:(v2策略)支持update,enable,disable

This commit is contained in:
wangxin
2020-06-16 19:40:59 +08:00
parent e9893ac45d
commit ca22cc7ba7
4 changed files with 140 additions and 5 deletions

View File

@@ -83,3 +83,10 @@ BaseEditRequest
Should Be Equal As Strings ${response.status_code} 200
${response} to json ${response.content}
[Return] ${response}
BaseEditRequestForV2
[Arguments] ${requestUri} ${data} ${apiVersion}
${apiStart} Evaluate '${requestUri}'[0:1]
${requestUri} Run Keyword If "${apiStart}"=="/" set variable /${apiVersion}${requestUri}
... ELSE set variable /${apiVersion}/${requestUri}
${response} BaseEditRequest ${requestUri} ${data}
[Return] ${response}

View File

@@ -74,4 +74,18 @@ AddPolicies
${policyIds} Run Keyword If "${returnData}" == "1" WxGet-PolicyIds ${response}
... ELSE Create List
${rescode} Set Variable ${response['code']}
[Return] ${rescode} ${policyIds}
[Return] ${rescode} ${policyIds}
UpdatePolicies
[Arguments] ${returnData} ${policyList} ${version} ${opAction}
Log To Console Call UpdatePolicies
${returnData}= Run Keyword If '${returnData}' == '${EMPTY}' Set Variable 1
... ELSE Set Variable ${returnData}
#必选参数判定
Should Not Be Empty ${policyList}
${dictType} = Evaluate type(${policyList})
${body} Run Keyword If "${dictType}" == "<class 'list'>" WxPolicyListOperation ${returnData} ${policyList} ${opAction} ${version}
... ELSE IF "${dictType}" == "<class 'dict'>" WxPolicyOperation ${returnData} ${policyList} ${opAction} ${version}
... ELSE Set Variable ${EMPTY}
${response} BaseEditRequestForV2 ${url} ${body} ${version}
${rescode} Set Variable ${response['code']}
[Return] ${rescode}

View File

@@ -33,7 +33,7 @@ Resource ../../tsg_common/ManagePolicyBody.robot
# ... 一个filter中的protocolFiled是确定的一个protocolFiled对应多个objectId
WxPolicyListOperation
[Documentation]
... 描述入口opAction参数固定为'add'
... 描述入口opAction参数为'add','update','disable','enable'
... 参数returnData: 必传,是否返回请求数据。可选${0}(不返回)/${1}(返回)。
... policyList: 必传,字典类型。字典内可选参数信息:
... policyObjectVersion: 必传v1,v2,涉及策略版本
@@ -57,7 +57,7 @@ WxPolicyListOperation
WxPolicyOperation
[Documentation]
... 描述入口opAction参数固定为'add'
... 描述入口opAction参数为'add','update','disable','enable'
... 参数returnData: 必传,是否返回请求数据。可选${0}(不返回)/${1}(返回)。
... policyList: 必传,字典类型。字典内可选参数信息:
... policyObjectVersion: 必传v1,v2,涉及策略版本
@@ -77,7 +77,7 @@ WxPolicyOperation
WxPolicyOrganize
[Documentation]
... 描述入口opAction参数固定为'add'
... 描述入口opAction参数为'add','update','disable','enable'
... policyList: 必传,字典类型。字典内可选参数信息:
... 其它参数默认值见../../03-Variable/PolicyObjectDefault.txt
... policyObjectVersion: 必传v1,v2,涉及策略版本
@@ -93,6 +93,14 @@ WxPolicyOrganize
Run Keyword If "${policyObjectVersion}"=="v2" Dictionary Should Not Contain Key ${policy} referenceObject
Run Keyword If "${policyObjectVersion}"=="v2" Dictionary Should Not Contain Key ${policy} appObjectIdArray
#更新时 policyId不允许为空
${return} ${policyId} Run Keyword And Ignore Error Get From Dictionary ${policy} policyId
Run Keyword If "${opAction}"=="update" and "${return}"=="FAIL" Fail policyId is required when opAction is update
Run Keyword If "${opAction}"=="update" and "${policyId}"=="${EMPTY}" Fail policyId is required when opAction is update
Run Keyword If "${opAction}"=="disable" and "${return}"=="FAIL" Fail policyId is required when opAction is disable
Run Keyword If "${opAction}"=="disable" and "${policyId}"=="${EMPTY}" Fail policyId is required when opAction is disable
Run Keyword If "${opAction}"=="enable" and "${return}"=="FAIL" Fail policyId is required when opAction is enable
Run Keyword If "${opAction}"=="enable" and "${policyId}"=="${EMPTY}" Fail policyId is required when opAction is enable
# 取可选参数,为传入设置默认值
${return} ${policyName} Run Keyword And Ignore Error Get From Dictionary ${policy} policyName
@@ -116,6 +124,9 @@ WxPolicyOrganize
Run Keyword If "${return}"=="FAIL" or "${isValid}"=="${EMPTY}" Set To Dictionary ${policy} isValid=${Default_IsValid}
${return} ${scheduleId} Run Keyword And Ignore Error Set Variable ${policy}[scheduleId]
Run Keyword If "${opAction}"=="enable" Set To Dictionary ${policy} isValid=1
Run Keyword If "${opAction}"=="disable" Set To Dictionary ${policy} isValid=0
${scheduleIdV} Run Keyword If "${return}"!="FAIL" and "${scheduleId}"!="${EMPTY}" and "${scheduleId}"!="${None}" Evaluate list(map(int, re.split('[,]', '${scheduleId}'))) re
... ELSE Set Variable ${emptyList}
Set To Dictionary ${policy} scheduleId=${scheduleIdV}