From 358445c174629bdd55894c48eaf965bbfd4414b2 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Wed, 24 Sep 2014 14:52:34 +0100 Subject: [PATCH] Drop redundant OPTIONS tests --- tests/test_generics.py | 180 ----------------------------------------- 1 file changed, 180 deletions(-) diff --git a/tests/test_generics.py b/tests/test_generics.py index 51004edfe..89f9def01 100644 --- a/tests/test_generics.py +++ b/tests/test_generics.py @@ -23,25 +23,16 @@ class ForeignKeySerializer(serializers.ModelSerializer): class RootView(generics.ListCreateAPIView): - """ - Example description for OPTIONS. - """ queryset = BasicModel.objects.all() serializer_class = BasicSerializer class InstanceView(generics.RetrieveUpdateDestroyAPIView): - """ - Example description for OPTIONS. - """ queryset = BasicModel.objects.exclude(text='filtered out') serializer_class = BasicSerializer class FKInstanceView(generics.RetrieveUpdateDestroyAPIView): - """ - FK: example description for OPTIONS. - """ queryset = ForeignKeySource.objects.all() serializer_class = ForeignKeySerializer @@ -122,47 +113,6 @@ class TestRootView(TestCase): self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED) self.assertEqual(response.data, {"detail": "Method 'DELETE' not allowed."}) - # def test_options_root_view(self): - # """ - # OPTIONS requests to ListCreateAPIView should return metadata - # """ - # request = factory.options('/') - # with self.assertNumQueries(0): - # response = self.view(request).render() - # expected = { - # 'parses': [ - # 'application/json', - # 'application/x-www-form-urlencoded', - # 'multipart/form-data' - # ], - # 'renders': [ - # 'application/json', - # 'text/html' - # ], - # 'name': 'Root', - # 'description': 'Example description for OPTIONS.', - # 'actions': { - # 'POST': { - # 'text': { - # 'max_length': 100, - # 'read_only': False, - # 'required': True, - # 'type': 'string', - # "label": "Text comes here", - # "help_text": "Text description." - # }, - # 'id': { - # 'read_only': True, - # 'required': False, - # 'type': 'integer', - # 'label': 'ID', - # }, - # } - # } - # } - # self.assertEqual(response.status_code, status.HTTP_200_OK) - # self.assertEqual(response.data, expected) - def test_post_cannot_set_id(self): """ POST requests to create a new object should not be able to set the id. @@ -256,89 +206,6 @@ class TestInstanceView(TestCase): ids = [obj.id for obj in self.objects.all()] self.assertEqual(ids, [2, 3]) - # def test_options_instance_view(self): - # """ - # OPTIONS requests to RetrieveUpdateDestroyAPIView should return metadata - # """ - # request = factory.options('/1') - # with self.assertNumQueries(1): - # response = self.view(request, pk=1).render() - # expected = { - # 'parses': [ - # 'application/json', - # 'application/x-www-form-urlencoded', - # 'multipart/form-data' - # ], - # 'renders': [ - # 'application/json', - # 'text/html' - # ], - # 'name': 'Instance', - # 'description': 'Example description for OPTIONS.', - # 'actions': { - # 'PUT': { - # 'text': { - # 'max_length': 100, - # 'read_only': False, - # 'required': True, - # 'type': 'string', - # 'label': 'Text comes here', - # 'help_text': 'Text description.' - # }, - # 'id': { - # 'read_only': True, - # 'required': False, - # 'type': 'integer', - # 'label': 'ID', - # }, - # } - # } - # } - # self.assertEqual(response.status_code, status.HTTP_200_OK) - # self.assertEqual(response.data, expected) - - # def test_options_before_instance_create(self): - # """ - # OPTIONS requests to RetrieveUpdateDestroyAPIView should return metadata - # before the instance has been created - # """ - # request = factory.options('/999') - # with self.assertNumQueries(1): - # response = self.view(request, pk=999).render() - # expected = { - # 'parses': [ - # 'application/json', - # 'application/x-www-form-urlencoded', - # 'multipart/form-data' - # ], - # 'renders': [ - # 'application/json', - # 'text/html' - # ], - # 'name': 'Instance', - # 'description': 'Example description for OPTIONS.', - # 'actions': { - # 'PUT': { - # 'text': { - # 'max_length': 100, - # 'read_only': False, - # 'required': True, - # 'type': 'string', - # 'label': 'Text comes here', - # 'help_text': 'Text description.' - # }, - # 'id': { - # 'read_only': True, - # 'required': False, - # 'type': 'integer', - # 'label': 'ID', - # }, - # } - # } - # } - # self.assertEqual(response.status_code, status.HTTP_200_OK) - # self.assertEqual(response.data, expected) - def test_get_instance_view_incorrect_arg(self): """ GET requests with an incorrect pk type, should raise 404, not 500. @@ -415,53 +282,6 @@ class TestFKInstanceView(TestCase): ] self.view = FKInstanceView.as_view() - # def test_options_root_view(self): - # """ - # OPTIONS requests to ListCreateAPIView should return metadata - # """ - # request = factory.options('/999') - # with self.assertNumQueries(1): - # response = self.view(request, pk=999).render() - # expected = { - # 'name': 'Fk Instance', - # 'description': 'FK: example description for OPTIONS.', - # 'renders': [ - # 'application/json', - # 'text/html' - # ], - # 'parses': [ - # 'application/json', - # 'application/x-www-form-urlencoded', - # 'multipart/form-data' - # ], - # 'actions': { - # 'PUT': { - # 'id': { - # 'type': 'integer', - # 'required': False, - # 'read_only': True, - # 'label': 'ID' - # }, - # 'name': { - # 'type': 'string', - # 'required': True, - # 'read_only': False, - # 'label': 'name', - # 'max_length': 100 - # }, - # 'target': { - # 'type': 'field', - # 'required': True, - # 'read_only': False, - # 'label': 'Target', - # 'help_text': 'Target' - # } - # } - # } - # } - # self.assertEqual(response.status_code, status.HTTP_200_OK) - # self.assertEqual(response.data, expected) - class TestOverriddenGetObject(TestCase): """