Django REST Assured instantly test-covers your Django REST Framework based API.
Project description
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 mocking of authentication if a user factory is provided.
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:
Supports
Tests run against:
Django 1.6, 1.7 & 1.8.
Django REST Framework 2.4.3, 2.4.4, 3.0, 3.1, 3.2 & 3.3.
Python 2.7, 3.2, 3.3 & 3.4.
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!
Running tests
$ python runtests.py
License
Django-REST-Assured is distributed under the BSD license.
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 Distribution
Hashes for django-rest-assured-0.2.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e2a0ad0251eab7f2f6a3d47558da244e26f2f8de70d4c0a66da91238b87e5ba9 |
|
MD5 | ba1836976835777a4d16e5ff6ab41830 |
|
BLAKE2b-256 | f0adaca033199874712d8cb6161770c827ee14ac8baca5e02d1e4bb596ca777e |