Пример #1
0
 def test_finalize_response_debug_false(self):
     factory = APIRequestFactory()
     request = factory.get("/test_resources")
     response = Response({"data": {}})
     view = TestViewSet()
     view.headers = {}
     decorated_response = view.finalize_response(request, response)
     self.assertNotIn("meta", decorated_response.data)
Пример #2
0
 def paged_list(self, request):
     items = range(100)
     self.apply_pagination(items)
     return Response(self.document.data)
Пример #3
0
 def list(self, request):
     return Response("OK")
Пример #4
0
 def test_init_with_context(self):
     context = {"key": "value"}
     response = Response(context=context)
     self.assertDictEqual(response.context, context)
Пример #5
0
 def test_created_false(self):
     response = Response(status=status.HTTP_200_OK)
     self.assertFalse(response.created)
Пример #6
0
 def test_created_true(self):
     response = Response(status=status.HTTP_201_CREATED)
     self.assertTrue(response.created)
Пример #7
0
 def test_ok_error(self):
     response = Response(status=status.HTTP_400_BAD_REQUEST)
     self.assertFalse(response.ok)
Пример #8
0
 def test_ok_success(self):
     response = Response(status=status.HTTP_200_OK)
     self.assertTrue(response.ok)