Test for Django REST API framework
-
There is my functional test
from rest_framework import status from rest_framework.test import APITestCase __all__ = ['OAuthTestCase'] ADDRESS_FOR_TEST = 'http://127.0.0.1:8000/api/v1/request/' class ApiOAuthTestCase (APITestCase): def setUp (self): User.objects.create_user (username = user_name, password = user_password) self.my_message = { 'grant_type': 'password', 'username': "user_name", 'password': "user_password", 'client_id': "secret_ket", 'client_secret': "clietn_id", } def test_token (self): response = self.client.post (ADDRESS_FOR_TEST, self.my_message) self.assertEqual (response.status_code, status.HTTP_201_CREATED)
When passing this test, error 400 appears. Can you please tell me how to access the response content from response?
-
The content of the response you can access using:
response.content