diff options
Diffstat (limited to 'keyword/common/api_request.robot')
| -rw-r--r-- | keyword/common/api_request.robot | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/keyword/common/api_request.robot b/keyword/common/api_request.robot new file mode 100644 index 0000000..3325e2a --- /dev/null +++ b/keyword/common/api_request.robot @@ -0,0 +1,52 @@ +*** Settings ***
+Library Collections
+Library json
+Library RequestsLibrary
+Resource ../../variable/common_variable.txt
+
+*** Keywords ***
+PostRequest1
+ [Arguments] ${url} ${data}
+ ${header} Create Dictionary Content-Type=application/json Authorization=${token}
+ Create Session api http://${host}:${port} headers=${header}
+ #${data1} json.dumps ${data}
+ ${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}
+
+GetRequest1
+ [Arguments] ${url}
+ ${header} Create Dictionary Content-Type=application/json Authorization=${token}
+ Create Session api http://${host}:${port} 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}
+
+DeleteRequest1
+ [Arguments] ${url} ${data}
+ ${header} Create Dictionary Content-Type=application/json Authorization=${token}
+ Create Session api http://${host}:${port} 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} 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} 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}
|
