Skip to content

Commit

Permalink
Add schemathesis tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
DanLipsitt committed Feb 10, 2022
1 parent 9a7be3f commit aa2b841
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/dev.requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ requests
asynctest
psycopg2
pyodbc
schemathesis

# Linting
flake8
Expand Down
25 changes: 25 additions & 0 deletions tests/test_schemathesis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import pytest
import schemathesis
from fastapi import FastAPI
from schemathesis.specs.openapi.schemas import BaseOpenAPISchema


@pytest.fixture()
def app_schema(client) -> BaseOpenAPISchema:
"""
Get an OpenAPI schema instance for the app created by the `client` fixture.
"""
app: FastAPI = client.app
assert client.app is not None
openapi = app.openapi()
result = schemathesis.from_dict(openapi)
return result


schema = schemathesis.from_pytest_fixture("app_schema")


@schema.parametrize()
def test_api(case):
"""Run tests automatically generated by schemathesis."""
case.call_and_validate()

0 comments on commit aa2b841

Please sign in to comment.