Skip to main content

Bravado Django Test Client

Project description

Bravado Django Test Client

Build Status

Django Test Client compatible HTTP Client with Bravado.

This allows your Django API and OpenAPI v2 (Swagger) specification files to be tested against each other in your unit tests. The aim being to quickly highlight any potential discrepancies between the specification and your actual API.

Basic Usage

from bravado.client import SwaggerClient
from bravado.swagger_model import load_file
from bravado_django_test_client.django_test_client import DjangoTestHttpClient
from bravado_django_test_client.config import config
from rest_framework.test import APIClient


swagger_file = load_file("schema.yaml")

test_client = APIClient()  # or the standard django test client

bravado_http_client = DjangoTestHttpClient(test_client)

client = SwaggerClient.from_spec(swagger_file, http_client=bravado_http_client, config=config)

# now use as you would a normal bravado client
pet_result = client.pet.getPetById(petId=42).response().result

# any request or response that doesnt match your schema will raise an exception

See the tests directory for a more complete example.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bravado_django_test_client-1.0.1.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bravado_django_test_client-1.0.1-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file bravado_django_test_client-1.0.1.tar.gz.

File metadata

  • Download URL: bravado_django_test_client-1.0.1.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.7

File hashes

Hashes for bravado_django_test_client-1.0.1.tar.gz
Algorithm Hash digest
SHA256 1e4c704621e38600f08981122ae674de698c5421498429fac6b28d8137f8ea2e
MD5 3a090c249e69eb9c7f75a2663145c059
BLAKE2b-256 3f583833e982736a0808018d257d7246afa0fd35426543cb86f8af5e6ae49c35

See more details on using hashes here.

File details

Details for the file bravado_django_test_client-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: bravado_django_test_client-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.7

File hashes

Hashes for bravado_django_test_client-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3ad0cea026d3e05dee550259f589838b92252f9558ea1e7e11b02a32599b2780
MD5 6ddb22da33867beaa8a731bc6ac80d76
BLAKE2b-256 a8b4e5d8a74150a76eea61939760465e7454850134b9294421328e20397626ae

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page