Skip to main content
Build 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 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

Support is determined by which Django versions are supported, and the Python and Django REST Framework versions that go with them. Tests run against all Django versions supported as of July 28, 2020.

  • Django 1.11 with Django REST Framework 3.4 - 3.6 and Python 2.7 and 3.5.

  • Django 2.1 and 2.2 with Django REST Framework 3.7-3.10 and Python 3.5-3.8.

  • Django 3.0 with Django REST Framework 3.10 and Python 3.7-3.8.

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

$ pip install pytest pytest-django
$ py.test

License

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

Metadata

Release files for django-rest-assured 0.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-rest-assured 0.2.3
File Size Uploaded
django-rest-assured-0.2.3.tar.gz 10.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-rest-assured 0.2.3
File Interpreter ABI Platform
django_rest_assured-0.2.3-py3-none-any.whl Python 3 none any Details

Total release size: 25.4 kB

Release files / django-rest-assured-0.2.3.tar.gz

Download URL django-rest-assured-0.2.3.tar.gz
Size 10.2 kB
Tags Source
SHA-256 checksum
How to use checksums
e031ed873cd33ae70b878e369188ba310aa07a07b77329668bec6a53c9b83adb
BLAKE2b-256 checksum
How to use checksums
0278c2245e4f581682d90df1ffff0da4ba38ac0e236e95de0cbd6de52ad674fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.7.3

Release files / django_rest_assured-0.2.3-py3-none-any.whl

Download URL django_rest_assured-0.2.3-py3-none-any.whl
Size 15.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
634da24cd31fd5fa18b995427bc63abcf8e6ac8b1ff1b8270e8099eeab30c933
BLAKE2b-256 checksum
How to use checksums
86103d27ed02ddbe4ac0c27b18f185cccce9e44bc6a925a76608aece753497dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.7.3

Release history Release notifications | RSS feed

This release

0.2.3 This release

2 release files

0.2.2

2 release files

0.2.1

1 release file

0.2.0

1 release file

0.1

1 release file

0.0.11

1 release file

0.0.10

1 release file

0.0.9

1 release file

0.0.8

1 release file

0.0.7

1 release file

0.0.6

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page