diff --git a/tests/test_routers.py b/tests/test_routers.py index b4bde5c31..8c6d5f60a 100644 --- a/tests/test_routers.py +++ b/tests/test_routers.py @@ -42,6 +42,10 @@ class NoteViewSet(viewsets.ModelViewSet): lookup_field = 'uuid' +class NotesWithoutPatchViewSet(NoteViewSet): + partial_update = None + + class KWargedNoteViewSet(viewsets.ModelViewSet): queryset = RouterTestModel.objects.all() serializer_class = NoteSerializer @@ -106,6 +110,9 @@ notes_router.register(r'notes', NoteViewSet) notes_path_router = SimpleRouter(use_regex_path=False) notes_path_router.register('notes', NoteViewSet) +notes_without_patch_path_router = SimpleRouter(use_regex_path=False) +notes_without_patch_path_router.register('notes', NotesWithoutPatchViewSet) + notes_path_default_router = DefaultRouter(use_regex_path=False) notes_path_default_router.register('notes', NoteViewSet) @@ -499,6 +506,7 @@ class TestUrlPath(URLPatternsTestCase, TestCase): path('path/', include(url_path_router.urls)), path('default/', include(notes_path_default_router.urls)), path('example/', include(notes_path_router.urls)), + path('methods/', include(notes_without_patch_path_router.urls)), ] def setUp(self): @@ -543,6 +551,14 @@ class TestUrlPath(URLPatternsTestCase, TestCase): assert response.status_code == 200 assert response.data == {"url": "http://testserver/example/notes/123/", "uuid": "123", "text": "foo bar example"} + def test_disabled_partial_update(self): + updated_note = { + 'text': 'foo bar example' + } + + response = self.client.patch('/methods/notes/123/', data=updated_note) + assert response.status_code == 405 + def test_delete(self): response = self.client.delete('/example/notes/123/') assert response.status_code == 204