diff options
| author | Tom Christie | 2013-09-25 09:44:26 +0100 |
|---|---|---|
| committer | Tom Christie | 2013-09-25 09:44:26 +0100 |
| commit | 21cd6386593aea0b122abec1c5cc3bd5c544aa87 (patch) | |
| tree | b7d197c9c04f56448bee36c4789c93c66fb541a8 /rest_framework/tests/test_generics.py | |
| parent | 9a5b2eefa92dede844ab94d049093e91ac98af5b (diff) | |
| parent | e8c6cd5622f62fcf2d4cf2b28b504fe5ff5228f9 (diff) | |
| download | django-rest-framework-21cd6386593aea0b122abec1c5cc3bd5c544aa87.tar.bz2 | |
Merge master
Diffstat (limited to 'rest_framework/tests/test_generics.py')
| -rw-r--r-- | rest_framework/tests/test_generics.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/rest_framework/tests/test_generics.py b/rest_framework/tests/test_generics.py index 7a87d389..79cd99ac 100644 --- a/rest_framework/tests/test_generics.py +++ b/rest_framework/tests/test_generics.py @@ -272,6 +272,48 @@ class TestInstanceView(TestCase): 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. |
