diff --git a/02-Keyword/tsg_bfapi/policy_object/Policy.robot b/02-Keyword/tsg_bfapi/policy_object/Policy.robot index f61e597..bb8e113 100644 --- a/02-Keyword/tsg_bfapi/policy_object/Policy.robot +++ b/02-Keyword/tsg_bfapi/policy_object/Policy.robot @@ -110,7 +110,15 @@ ImportPolicy Directory Should Exist ${path} File Should Exist ${path}/${filePath}/${fileName} File Should Not Be Empty ${path}/${filePath}/${fileName} - ${size} Get File Size ${path}/${filePath}/${fileName} + #获取导入策略总数 + ${file} Get File ${path}/${filePath}/${fileName} + ${fileJson} json.Loads ${file} + #待导入的策略总数 + ${totalNum} Get From Dictionary ${fileJson} totalNum + #查询已经导入的非内置策略的数量 + ${totalExists} GetPolicyTotal 2 + ${calTotal} Evaluate ${totalNum} + ${totalExists} + Run Keyword If ${calTotal}>1000000 Fail 当前已经存在策略条数${totalExists},待导入条数${totalNum},总数超过100万条! ${binFile} Evaluate (r'import_policy.json',open(r"${path}/${filePath}/${fileName}",'rb'),'application/json') Log ${binFile} ${data} Create Dictionary policyType=${policyType} @@ -165,4 +173,16 @@ VerifyPolicies ${response} BasePostRequestForV2 /policy/verify ${body} ${version} ${rescode} Set Variable ${response['code']} Should Be Equal As Strings ${rescode} 200 - [Return] ${rescode} ${response['data']} \ No newline at end of file + [Return] ${rescode} ${response['data']} +GetPolicyTotal + [Documentation] + ... 获取已经存在的策略总量 + ... 排除内置策略 + ... initializeNum内置策略数量 + [Arguments] ${initializeNum} + ${response} BaseFormRequest ${policyUrl}/statistics ${EMPTY} ${version} + ${rescode} Set Variable ${response['code']} + Should Be Equal As Strings ${rescode} 200 + ${total} Set Variable ${response['data']['policyNum']} + ${total} Evaluate ${total} - ${initializeNum} + [Return] ${total} \ No newline at end of file