Request
This module contains step implementations that creates requests executed by the Load User in the scenario.
Then request text with name endpoint
Then {method:Method} request with name "{name}" {direction:Direction} endpoint "{endpoint}"
Create an instance of the Request task, where optional payload is defined directly in the feature file.
See Request task documentation for more information about arguments.
-
If
Method
in the expression isget
orreceive
; thedirection
must befrom
. -
If
Method
in the expression ispost
,pust
, orsend
; thedirection
must beto
, and payload defined in the feature file.
Example:
Then post request with name "test-post" to endpoint "/api/test"
"""
{
"test": "hello world"
}
"""
Then put request with name "test-put" to endpoint "/api/test"
"""
{
"test": "hello world"
}
"""
Then get request with name "test-get" from endpoint "/api/test"
Then send request with name "test-send" to endpoint "queue:receive-queue"
"""
{
"value": "do something"
}
"""
Then receive request with name "test-receive" from endpoint "queue:receive-queue"
Arguments:
method
Method - type of request, either of type "from" or "to"name
str - name of the requests in logs, can contain variablesdirection
RequestDirection - one ofto
orfrom
depending on the value ofmethod
endpoint
str - URI relative tohost
in the scenario, can contain variables and in certain casesuser_class_name
specific parameters
Then request file with name endpoint
Then {method:Method} request "{source}" with name "{name}" to endpoint "{endpoint}"
Create an instance of the Request task, where the payload is defined in a template file.
See Request task documentation for more information about arguments.
Example:
Then send request "test/request.j2.json" with name "test-send" to endpoint "queue:receive-queue"
Then post request "test/request.j2.json" with name "test-post" to endpoint "/api/test"
Then put request "test/request.j2.json" with name "test-put" to endpoint "/api/test"
Arguments:
method
Method - type of "to" requestsource
str - path to a template file relative to the directoryrequests/
, which must exist in the directory the feature file is locatedname
str - name of the requests in logs, can contain variablesendpoint
str - URI relative tohost
in the scenario, can contain variables and in certain casesuser_class_name
specific parameters
Then request file with name
Then {method:Method} request "{source}" with name "{name}"
Create an instance of the Request task, with the same endpoint
as the previous Request task, where the
payload is defined in a template file.
See Request task documentation for more information about arguments.
Example:
Then post request "test/request1.j2.json" with name "test-post1" to endpoint "/api/test"
Then post request "test/request2.j2.json" with name "test-post2"
# same as
Then post request "test/request1.j2.json" with name "test-post1" to endpoint "/api/test"
Then post request "test/request2.j2.json" with name "test-post2" to endpoint "/api/test"
Arguments:
method
Method - type of "to" requestsource
str - path to a template file relative to the directoryrequests/
, which must exist in the directory the feature file is locatedname
str - name of the requests in logs, can contain variables
Then request text with name
Then {method:Method} request with name "{name}"
Create an instance of the Request task, where optional payload is defined directly in the feature file.
See Request task documentation for more information about arguments.
If method
in the expression is post
, put
or send
the payload in the request must be defined directly in the feature file after the step.
This step is useful if method
and endpoint
are the same as previous request, but the payload should be different.
Example:
# example-1
Then post request with name "test-post-1" to endpoint "/api/test"
"""
{
"value": "hello world!"
}
"""
Then post request with name "test-post-2"
"""
{
"value": "i have good news!"
}
"""
# same as example-1
Then post request with name "test-post-1" to endpoint "/api/test"
"""
{
"value": "hello world!"
}
"""
Then post request with name "test-post-2" to endpoint "/api/test"
"""
{
"value": "i have good news!"
}
"""
# example-2
Then get request with name "test-get-1" from endpoint "/api/test"
Then get request with name "test-get-2"
# same as example-2
Then get request with name "test-get-1" from endpoint "/api/test"
Then get request with name "test-get-2" from endpoint "/api/test"
Arguments:
method
Method - type of request, either "from" or "to"name
str - name of the requests in logs, can contain variables