Skip to main content
Downloads Latest Version License

Instantly test-cover your Django REST Framework based API.

Django-REST-Assured adds another layer on top of Django REST Framework’s APITestCase which allows covering a set of RESTful resource’s endpoints with a single class declaration.

This gives both a quick coverage of sanity tests to your API and a more DRY and more friendly platform for writing additional, more comprehensive tests.

As easy as

class CategoryTestCase(ReadWriteRESTAPITestCaseMixin, BaseRESTAPITestCase):

    base_name = 'category'
    factory_class = CategoryFactory
    create_data = {'name': 'comedy'}
    update_data = {'name': 'horror'}

Django-REST-Assured is designed to work with factory_boy for mocking objects to test against. However, you can easily extend the BaseRESTAPITestCase to work directly with Django Models or any other factory.

Main features

  • Class-based declarative API for creating tests.

  • Covers the stack through: route > view > serializer > model.

  • Uses Django REST Framework’s conventions to minimize configuration.

  • All tests return the response object for more extensive assertions.

  • Automatic login via session or token authentication.

Usage

The basic form of usage is simply to create a class that extends any mixin from rest_assured.testcases, according to the endpoints you wish to cover, and the BaseRESTAPITestCase class.

Then just set the required attributes, and continue extending it from there.

If your API requires authentication and/or authorization just add a user factory class. Assuming you use factory_boy:

Requirements

  • Django >= 1.6

  • Django REST Framework >= 2.4.3

Currently developed only for python 2.7.

Installation

PyPI: https://pypi.python.org/pypi/django-rest-assured

$ pip install django-rest-assured

Source: https://github.com/ydaniv/django-rest-assured

$ git clone https://github.com/ydaniv/django-rest-assured
$ python setup.py install

Contributing

Issues are tracked in the github repository.

Pull requests are welcome!

License

Django-REST-Assured is distributed under the BSD license.

Download files

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

Source Distribution

django-rest-assured-0.0.9.tar.gz (6.8 kB view details)

Uploaded Source

File details

Details for the file django-rest-assured-0.0.9.tar.gz.

File metadata

File hashes

Hashes for django-rest-assured-0.0.9.tar.gz
Algorithm Hash digest
SHA256 6700c8748131e6aa99a2a42a8c359ea52e7a81cbb37605aebb5262f5562fc35b
MD5 ee09d76d15db062085d2012bd7ff3d5a
BLAKE2b-256 4777de8a767b8bf8e0435a196cb5051272ca80ff9b4194aab5474eb4f06bef15

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 Sentry Error logging StatusPage Status page