Skip to content

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}"

[view_source]

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 get or receive; the direction must be from.

  • If Method in the expression is post, pust, or send; the direction must be to, 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 variables
  • direction RequestDirection - one of to or from depending on the value of method
  • endpoint str - URI relative to host in the scenario, can contain variables and in certain cases user_class_name specific parameters

Then request file with name endpoint

Then {method:Method} request "{source}" with name "{name}" to endpoint "{endpoint}"

[view_source]

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" request
  • source str - path to a template file relative to the directory requests/, which must exist in the directory the feature file is located
  • name str - name of the requests in logs, can contain variables
  • endpoint str - URI relative to host in the scenario, can contain variables and in certain cases user_class_name specific parameters

Then request file with name

Then {method:Method} request "{source}" with name "{name}"

[view_source]

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" request
  • source str - path to a template file relative to the directory requests/, which must exist in the directory the feature file is located
  • name str - name of the requests in logs, can contain variables

Then request text with name

Then {method:Method} request with name "{name}"

[view_source]

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