summaryrefslogtreecommitdiff
path: root/02-Keyword/tsg_bfapi/ApiRequest.robot
blob: 6226ba8c1a5c0e4abf4e5a461953ca7529b435fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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}