mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-10 19:56:59 +03:00
Added a test to cover the DjangoModelPermissions #4927 issue
`DjangoObjectPermissions` and `DjangoModelPermissions` are now properly cover for the `METHOD_NOT_ALLOWED` issue
This commit is contained in:
parent
e9a68e575a
commit
d616c1591f
|
@ -202,7 +202,11 @@ class ModelPermissionsIntegrationTests(TestCase):
|
|||
|
||||
def test_calling_method_not_allowed(self):
|
||||
request = factory.generic('METHOD_NOT_ALLOWED', '/')
|
||||
response = object_permissions_list_view(request)
|
||||
response = root_view(request)
|
||||
self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)
|
||||
|
||||
request = factory.generic('METHOD_NOT_ALLOWED', '/1')
|
||||
response = instance_view(request, pk='1')
|
||||
self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)
|
||||
|
||||
|
||||
|
@ -389,6 +393,11 @@ class ObjectPermissionsIntegrationTests(TestCase):
|
|||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
self.assertListEqual(response.data, [])
|
||||
|
||||
def test_cannot_method_not_allowed(self):
|
||||
request = factory.generic('METHOD_NOT_ALLOWED', '/')
|
||||
response = object_permissions_list_view(request)
|
||||
self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)
|
||||
|
||||
|
||||
class BasicPerm(permissions.BasePermission):
|
||||
def has_permission(self, request, view):
|
||||
|
|
Loading…
Reference in New Issue
Block a user