summaryrefslogtreecommitdiff
path: root/keyword/common/api_request.robot
diff options
context:
space:
mode:
author董晓燕 <[email protected]>2021-06-03 09:55:45 +0000
committer董晓燕 <[email protected]>2021-06-03 09:55:45 +0000
commitac68e65f508799a0e555a240ae374d313a0a8d75 (patch)
tree2a339bbd8acd65e2fb235159cc9c5303ae5725b7 /keyword/common/api_request.robot
parent2f39b56d617e5fba2b8d73d81cd5e6d894f85352 (diff)
parent4667c668725ff7cb673c637a297c67283876d4d4 (diff)
Merge branch 'develop' into 'master'HEADmaster
Develop See merge request dongxiaoyan/gap_tsg_api!4
Diffstat (limited to 'keyword/common/api_request.robot')
-rw-r--r--keyword/common/api_request.robot52
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}