Hypothesis strategies for Open API
Project description
Schemathesis
Schemathesis is a tool that generates test cases for your Open API / Swagger schemas.
The main goal is to verify if all values allowed by the schema are processed correctly by the application.
Empowered with Hypothesis
, hypothesis_jsonschema
and pytest
.
NOTE: The library is WIP, the API is a subject to change.
Usage
To generate test cases for your schema you need:
- Create a parametrizer;
- Wrap a test with
Parametrizer.parametrize
method
from schemathesis import Parametrizer
schema = Parametrizer.from_path("path/to/schema.yaml")
@schema.parametrize()
def test_users_endpoint(client, case):
response = client.request(
case.method,
case.formatted_path,
params=case.query,
json=case.body
)
assert response.status_code == 200
Each wrapped test will have the case
fixture, that represents a hypothesis test case.
Case consists of:
method
formatted_path
query
body
This data could be used to verify that your application works in the way as described in the schema.
For example the data could be send against running app container via requests
and response is checked
for an expected status code or error message.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Hashes for schemathesis-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64822982fc761ea7fbb9447559b9dbc114341e039461e7b8c9a8265b505d2176 |
|
MD5 | 57b6ed32c898d5389ac8307d00fc9fe9 |
|
BLAKE2b-256 | ed0725ab8fda1dcaf39f13989e6287f30e6733af63a3c88fdb34223f2ff21f04 |