O'Reilly logo

Test-Driven Development with Django by Kevin Harvey

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Introducing Django REST framework

Now that we've got some idea what we're building, let's actually get it going. We'll be using Django REST Framework (http://www.django-rest-framework.org/). Start by installing it in your environment:

$ pip install djangorestframework

Add rest_framework to your INSTALLED_APPS in jmad/settings.py:

INSTALLED_APPS = (
    ...
    'rest_framework'
)

Now we're ready to start testing.

Writing tests for API endpoints

While there's no such thing as browser-based testing for an external API, it is important to write tests that cover its end-to-end processing. We need to be able to send in requests like the ones we've documented and confirm that we receive the responses our documentation promises.

Django REST Framework (DRF from here ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required