Skip to content

Commit

Permalink
docs: Add a recipe for per-route timeouts
Browse files Browse the repository at this point in the history
Ref: #1266
  • Loading branch information
Stranger6667 committed Nov 1, 2021
1 parent eea6e61 commit b804378
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions docs/recipes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,31 @@ Sometimes you need to send your traffic to some other tools. You could set up a
$ export HTTP_PROXY="http://10.10.1.10:3128"
$ export HTTPS_PROXY="http://10.10.1.10:1080"
$ schemathesis run http://localhost/schema.json
Per-route request timeouts
--------------------------

Different API operations may need different timeouts during testing. You could achieve it this way:

.. code-block:: python
import schemathesis
DEFAULT_TIMEOUT = 10 # in seconds
SCHEMA_URL = "http://localhost/schema.json"
schema = schemathesis.from_uri(SCHEMA_URL)
@schema.parametrize()
def test_api(case):
key = (
case.operation.method.upper(),
case.operation.path,
)
timeout = {
("GET", "/users"): 5,
# and so on
}.get(key, DEFAULT_TIMEOUT)
case.call_and_validate(timeout=timeout)
In the example above, the default timeout is 10 seconds, but for `GET /users` it will be 5 seconds.

0 comments on commit b804378

Please sign in to comment.