mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-22 09:36:49 +03:00
Add test for non-GET methods to api_view decorator
This commit is contained in:
parent
2a89cb4fb7
commit
7218bcbade
|
@ -379,7 +379,8 @@ class HyperlinkedIdentityField(Field):
|
|||
A field that represents the model's identity using a hyperlink.
|
||||
"""
|
||||
def __init__(self, *args, **kwargs):
|
||||
# TODO: Make this mandatory
|
||||
# TODO: Make this mandatory, and have the HyperlinkedModelSerializer
|
||||
# set it on-the-fly
|
||||
self.view_name = kwargs.pop('view_name', None)
|
||||
super(HyperlinkedIdentityField, self).__init__(*args, **kwargs)
|
||||
|
||||
|
|
|
@ -49,6 +49,20 @@ class DecoratorTestCase(TestCase):
|
|||
response = view(request)
|
||||
self.assertEqual(response.status_code, 405)
|
||||
|
||||
def test_calling_put_method(self):
|
||||
|
||||
@api_view(['GET', 'PUT'])
|
||||
def view(request):
|
||||
return Response({})
|
||||
|
||||
request = self.factory.put('/')
|
||||
response = view(request)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
request = self.factory.post('/')
|
||||
response = view(request)
|
||||
self.assertEqual(response.status_code, 405)
|
||||
|
||||
def test_renderer_classes(self):
|
||||
|
||||
@api_view(['GET'])
|
||||
|
|
Loading…
Reference in New Issue
Block a user