diff options
| author | José Padilla | 2014-09-23 21:12:58 -0400 |
|---|---|---|
| committer | José Padilla | 2014-09-23 21:12:58 -0400 |
| commit | e8c01ecdabe2abda48dd0cf298d4b6c743574449 (patch) | |
| tree | 5944fd8f436a9a710109a0a3518c05df5d035aa9 /tests | |
| parent | 8495cd898a5d34f00858a379b54e39cd19ded215 (diff) | |
| download | django-rest-framework-e8c01ecdabe2abda48dd0cf298d4b6c743574449.tar.bz2 | |
Correctly propagate cloned_request for OPTIONS
Update to fix pending changes in #1507
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_generics.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/test_generics.py b/tests/test_generics.py index e9f5bebd..dd3bab18 100644 --- a/tests/test_generics.py +++ b/tests/test_generics.py @@ -681,3 +681,42 @@ class TestFilterBackendAppliedToViews(TestCase): response = view(request).render() self.assertContains(response, 'field_b') self.assertNotContains(response, 'field_a') + + def test_options_with_dynamic_serializer(self): + """ + Ensure that OPTIONS returns correct POST json schema: + DynamicSerializer with single field 'field_b' + """ + request = factory.options('/') + view = DynamicSerializerView.as_view() + + with self.assertNumQueries(0): + response = view(request).render() + + expected = { + 'name': 'Dynamic Serializer', + 'description': '', + 'renders': [ + 'text/html', + 'application/json' + ], + 'parses': [ + 'application/json', + 'application/x-www-form-urlencoded', + 'multipart/form-data' + ], + 'actions': { + 'POST': { + 'field_b': { + 'type': u'string', + 'required': True, + 'read_only': False, + 'label': u'field b', + 'max_length': 100 + } + } + } + } + + self.assertEqual(response.status_code, status.HTTP_200_OK) + self.assertEqual(response.data, expected) |
