Commit 2e0c8a7e authored by Martti Käärik's avatar Martti Käärik
Browse files

Added Robot example.

parent b9762ebb
Loading
Loading
Loading
Loading
+22 −0
Original line number Original line Diff line number Diff line

*** Settings ***
Library     BuiltIn
Library     OperatingSystem
Library     JSONSchemaLibrary           schemas/
Resource    ExampleAPIKeywords.robot

*** Test Cases ***

Get Resource 200
    [Documentation]
    ... Test case: TC_RESOURCE_GET_200
    ${resource}                           ${response} =            getResoure    1
    Should Be Equal                       ${response['status']}    200
    Should Be Equal                       ${resource['id']}        1

Post Resource 204
    [Documentation]
    ... Test case: TC_RESOURCE_POST_204
    ${resource} =                          Get File                 data/resourceData1.json
    ${response} =                          postResource             ${resource}
    Should Be Equal                        ${response['status']}    204
+23 −0
Original line number Original line Diff line number Diff line
# NOTE: depends on Python's json module

*** Settings ***
Resource    environment/variables.robot
Library     REST ${HTTP_SCHEME}://${IP_HOST}:${TCP_PORT}
Library     JSONLibrary
Library     JSONSchemaLibrary                               schemas/


*** Keywords ***
getResource ${id}
    Set Headers      {"Accept": "${ACCEPT_JSON}"}
    GET              ${apiRoot}/${apiName}/${apiVersion}/resource/${id}
    ${response} =    Output                                                response
    Validate Json    ResourceData.schema.json                              ${response['body']}
    ${resource} =    evaluate                                              json.loads('''${response['body']}''')    json
    [Return]         ${resource}                                           ${response}

postResource ${resource}
    Set Headers      {"Accept": "${ACCEPT_JSON}"}
    POST             ${apiRoot}/${apiName}/${apiVersion}/resource    ${resource}
    ${response} =    Output                                          response
    [Return]         ${response}
+3 −0
Original line number Original line Diff line number Diff line
{
    "size": "big"
}
 No newline at end of file
+3 −0
Original line number Original line Diff line number Diff line
{
    "type": "object"
}
 No newline at end of file
+3 −0
Original line number Original line Diff line number Diff line
{
    "type": "object"
}
 No newline at end of file
Loading