Коды состояния
from rest_framework import status
from rest_framework.response import Response
def empty_view(self):
content = {'please move along': 'nothing to see here'}
return Response(content, status=status.HTTP_404_NOT_FOUND)from rest_framework import status
from rest_framework.test import APITestCase
class ExampleTestCase(APITestCase):
def test_url_root(self):
url = reverse('index')
response = self.client.get(url)
self.assertTrue(status.is_success(response.status_code))Информационный - 1xx
Успешно - 2xx
Перенаправление - 3xx
Ошибка клиента - 4xx
Ошибка сервера - 5xx
Вспомогательные функции
Last updated
Was this helpful?