diff options
| author | Tom Christie | 2013-05-24 23:44:23 +0100 |
|---|---|---|
| committer | Tom Christie | 2013-05-24 23:44:23 +0100 |
| commit | fcaee6e580efc62658a5b155525c55ef427c5778 (patch) | |
| tree | f46d5966d96e52c6e77df73c0f7c19200a82f1c7 /rest_framework/tests/generics.py | |
| parent | 760e8642bd04b5e03409601a8d378799c36eac1b (diff) | |
| download | django-rest-framework-fcaee6e580efc62658a5b155525c55ef427c5778.tar.bz2 | |
Clean up OPTIONS implementation
Diffstat (limited to 'rest_framework/tests/generics.py')
| -rw-r--r-- | rest_framework/tests/generics.py | 74 |
1 files changed, 39 insertions, 35 deletions
diff --git a/rest_framework/tests/generics.py b/rest_framework/tests/generics.py index a2f8fb4b..f091d0db 100644 --- a/rest_framework/tests/generics.py +++ b/rest_framework/tests/generics.py @@ -122,21 +122,24 @@ class TestRootView(TestCase): ], 'name': 'Root', 'description': 'Example description for OPTIONS.', - 'actions': {} - } - expected['actions']['GET'] = {} - expected['actions']['POST'] = { - 'text': { - 'max_length': 100, - 'read_only': False, - 'required': True, - 'type': 'String', - }, - 'id': { - 'read_only': True, - 'required': False, - 'type': 'Integer', - }, + '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) @@ -239,9 +242,9 @@ class TestInstanceView(TestCase): """ OPTIONS requests to RetrieveUpdateDestroyAPIView should return metadata """ - request = factory.options('/') - with self.assertNumQueries(0): - response = self.view(request).render() + request = factory.options('/1') + with self.assertNumQueries(1): + response = self.view(request, pk=1).render() expected = { 'parses': [ 'application/json', @@ -254,24 +257,25 @@ class TestInstanceView(TestCase): ], 'name': 'Instance', 'description': 'Example description for OPTIONS.', - 'actions': {} - } - for method in ('GET', 'DELETE'): - expected['actions'][method] = {} - for method in ('PATCH', 'PUT'): - expected['actions'][method] = { - 'text': { - 'max_length': 100, - 'read_only': False, - 'required': True, - 'type': 'String', - }, - 'id': { - 'read_only': True, - 'required': False, - 'type': 'Integer', - }, + '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) |
