feat:(策略导入导出)上传文件下载文件以及样例

This commit is contained in:
wangxin
2020-06-19 19:13:50 +08:00
parent bc6b6ed90f
commit c24acb6bc3
4 changed files with 123 additions and 2 deletions

View File

@@ -107,4 +107,38 @@ WxDeletePolicy1
${response} BaseDeleteRequest /${version}${policyUrl} ${params}
${rescode} Set Variable ${response['code']}
Should Be Equal As Strings ${rescode} 200
[Return] ${rescode}
[Return] ${rescode}
ImportPolicy
[Documentation]
... 策略导入
[Arguments] ${filePath} ${fileName} ${policyType}
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}
${binFile} Evaluate (r'import_policy.json',open(r"${path}/${filePath}/${fileName}",'rb'),'application/json')
Log ${binFile}
${data} Create Dictionary policyType=${policyType}
${file} Create Dictionary file=${binFile}
${response} BaseMultipartPostRequest ${policyUrl}/batch ${data} ${file} ${version}
${rescode} Set Variable ${response['code']}
Should Be Equal As Strings ${rescode} 200
[Return] ${rescode}
ExportPolicy
[Documentation]
... 策略导出
[Arguments] ${policyType} ${policyIds} ${policyName}
Should Not Be Empty ${policyType}
${params} Create Dictionary policyType=${policyType}
Run Keyword If "${policyIds}"!="${EMPTY}" Set To Dictionary ${params} policyIds=${policyIds}
Run Keyword If "${policyName}"!="${EMPTY}" Set To Dictionary ${params} policyName=${policyName}
${paramsStr} Dictionary-To-QueryParams ${params}
${response} BaseFormRequest1 ${policyUrl}/batch ${paramsStr} ${version}
[Return] ${response}
WriteFile
[Arguments] ${filePath} ${fileName} ${content}
Create File ${path}/${filePath}/${fileName}
${type} Evaluate type(${content})
${content} Run Keyword If "${type}" == "<class 'dict'>" json.Dumps ${content}
... ELSE Set Variable ${content}
Append To File ${path}/${filePath}/${fileName} ${content}