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

Added Robot example.

parent b9762ebb
*** 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
# 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}
{
"size": "big"
}
\ No newline at end of file
{
"type": "object"
}
\ No newline at end of file
{
"type": "object"
}
\ No newline at end of file
{
"type": "object",
"properties": {
"id": {
"type": "string"
},
"size": {
"type": "string",
"enum": [
"big",
"bigger",
"biggerer"
],
"default": "big"
},
"created": {
"type": "string",
"format": "date-time"
}
},
"required": [
"id"
]
}
\ No newline at end of file
{
"type": "array",
"items": {
"$ref": "ResourceData.schema.json#/"
},
"maxItems": 10
}
\ No newline at end of file
{
"type": "object",
"properties": {
"credentials": {
"$ref": "Credentials.schema.json#/"
}
}
}
\ No newline at end of file
*** Variables ***
${HTTP_SCHEME} http
${IP_HOST} example.com
${TCP_PORT} 80
${apiRoot} /
${apiVersion}
${apiName} example
${ACCEPT_JSON} application/json
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment