Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
MTS - Methods for Testing and Specification
EG 203 647 - Specification and testing of RESTful APIs
Commits
2e0c8a7e
Commit
2e0c8a7e
authored
Jul 16, 2020
by
Martti Käärik
Browse files
Added Robot example.
parent
b9762ebb
Changes
9
Hide whitespace changes
Inline
Side-by-side
Robot/ExampleAPIBehaviour.robot
0 → 100644
View file @
2e0c8a7e
*** 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
Robot/ExampleAPIKeywords.robot
0 → 100644
View file @
2e0c8a7e
# 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}
Robot/data/resourceData1.json
0 → 100644
View file @
2e0c8a7e
{
"size"
:
"big"
}
\ No newline at end of file
Robot/schemas/AuthenticatedNotification.schema.json
0 → 100644
View file @
2e0c8a7e
{
"type"
:
"object"
}
\ No newline at end of file
Robot/schemas/Credentials.schema.json
0 → 100644
View file @
2e0c8a7e
{
"type"
:
"object"
}
\ No newline at end of file
Robot/schemas/ResourceData.schema.json
0 → 100644
View file @
2e0c8a7e
{
"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
Robot/schemas/SearchResults.schema.json
0 → 100644
View file @
2e0c8a7e
{
"type"
:
"array"
,
"items"
:
{
"$ref"
:
"ResourceData.schema.json#/"
},
"maxItems"
:
10
}
\ No newline at end of file
Robot/schemas/Subscription.schema.json
0 → 100644
View file @
2e0c8a7e
{
"type"
:
"object"
,
"properties"
:
{
"credentials"
:
{
"$ref"
:
"Credentials.schema.json#/"
}
}
}
\ No newline at end of file
Robot/variables.robot
0 → 100644
View file @
2e0c8a7e
*** 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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment