summaryrefslogtreecommitdiff
path: root/02-Keyword/tsg_bfapi/ApiRequest.robot
diff options
context:
space:
mode:
authordongxiaoyan <[email protected]>2020-04-01 12:42:05 +0800
committerdongxiaoyan <[email protected]>2020-04-01 12:42:05 +0800
commitacc676857bd85512f344a8d06aa1ae8846e7c0db (patch)
treef2a7e19139d7f763e699ae10a997184c168fed76 /02-Keyword/tsg_bfapi/ApiRequest.robot
first init project codeHEADmaster
Diffstat (limited to '02-Keyword/tsg_bfapi/ApiRequest.robot')
-rw-r--r--02-Keyword/tsg_bfapi/ApiRequest.robot50
1 files changed, 50 insertions, 0 deletions
diff --git a/02-Keyword/tsg_bfapi/ApiRequest.robot b/02-Keyword/tsg_bfapi/ApiRequest.robot
new file mode 100644
index 0000000..6226ba8
--- /dev/null
+++ b/02-Keyword/tsg_bfapi/ApiRequest.robot
@@ -0,0 +1,50 @@
+*** Settings ***
+Library Collections
+Library RequestsLibrary
+Resource ../../03-Variable/BifangApiVariable.txt
+
+*** Keywords ***
+Post-Request
+ [Arguments] ${url} ${data}
+ ${header} Create Dictionary Content-Type=application/json Authorization=${token}
+ Create Session api http://${host}:${port}/${version} headers=${header}
+ ${remoteResponse} Post Request api ${url} data=${data} headers=${header}
+ ${response} to json ${remoteResponse.content}
+ Should Be Equal As Strings ${remoteResponse.status_code} 200
+ [Return] ${response}
+
+Get-Request
+ [Arguments] ${url}
+ ${header} Create Dictionary Content-Type=application/json Authorization=${token}
+ Create Session api http://${host}:${port}/${version} headers=${header}
+ ${remoteResponse} Get Request api ${url} headers=${header}
+ ${response} to json ${remoteResponse.content}
+ Should Be Equal As Strings ${remoteResponse.status_code} 200
+ [Return] ${response}
+
+Delete-Request
+ [Arguments] ${url} ${data}
+ ${header} Create Dictionary Content-Type=application/json Authorization=${token}
+ Create Session api http://${host}:${port}/${version} headers=${header}
+ ${remoteResponse} Delete Request api ${url} data=${data} headers=${header}
+ ${response} to json ${remoteResponse.content}
+ Should Be Equal As Strings ${remoteResponse.status_code} 200
+ [Return] ${response}
+
+UpFilePostRequest
+ [Arguments] ${url} ${data} ${files} ${fileDesc}
+ ${header} Set To Dictionary ${fileDesc} Authorization=${token}
+ Create Session api http://${host}:${port}/${version} headers=${header}
+ ${remoteResponse} Post Request api ${url} data=${data} files=${files} headers=${header}
+ ${response} to json ${remoteResponse.content}
+ Should Be Equal As Strings ${remoteResponse.status_code} 200
+ [Return] ${response}
+
+UpFilePutRequest
+ [Arguments] ${url} ${data} ${files} ${fileDesc}
+ ${header} Set To Dictionary ${fileDesc} Authorization=${token}
+ Create Session api http://${host}:${port}/${version} headers=${header}
+ ${remoteResponse} Put Request api ${url} params=${data} files=${files} headers=${header}
+ ${response} to json ${remoteResponse.content}
+ Should Be Equal As Strings ${remoteResponse.status_code} 200
+ [Return] ${response}