mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-21 17:16:47 +03:00
tests: remove some dead code, use assert 0
for never called methods (#5973)
* tests: remove some dead code, use `assert 0` for never called methods * fixup! tests: remove some dead code, use `assert 0` for never called methods
This commit is contained in:
parent
4527a753cd
commit
275c157341
|
@ -1,3 +1,4 @@
|
||||||
|
import pytest
|
||||||
from django.conf.urls import include, url
|
from django.conf.urls import include, url
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.test import TestCase, override_settings
|
from django.test import TestCase, override_settings
|
||||||
|
@ -34,26 +35,26 @@ class ActionViewSet(GenericViewSet):
|
||||||
queryset = Action.objects.all()
|
queryset = Action.objects.all()
|
||||||
|
|
||||||
def list(self, request, *args, **kwargs):
|
def list(self, request, *args, **kwargs):
|
||||||
pass
|
raise NotImplementedError() # pragma: no cover
|
||||||
|
|
||||||
def retrieve(self, request, *args, **kwargs):
|
def retrieve(self, request, *args, **kwargs):
|
||||||
pass
|
raise NotImplementedError() # pragma: no cover
|
||||||
|
|
||||||
@action(detail=False)
|
@action(detail=False)
|
||||||
def list_action(self, request, *args, **kwargs):
|
def list_action(self, request, *args, **kwargs):
|
||||||
pass
|
raise NotImplementedError() # pragma: no cover
|
||||||
|
|
||||||
@action(detail=False, url_name='list-custom')
|
@action(detail=False, url_name='list-custom')
|
||||||
def custom_list_action(self, request, *args, **kwargs):
|
def custom_list_action(self, request, *args, **kwargs):
|
||||||
pass
|
raise NotImplementedError() # pragma: no cover
|
||||||
|
|
||||||
@action(detail=True)
|
@action(detail=True)
|
||||||
def detail_action(self, request, *args, **kwargs):
|
def detail_action(self, request, *args, **kwargs):
|
||||||
pass
|
raise NotImplementedError() # pragma: no cover
|
||||||
|
|
||||||
@action(detail=True, url_name='detail-custom')
|
@action(detail=True, url_name='detail-custom')
|
||||||
def custom_detail_action(self, request, *args, **kwargs):
|
def custom_detail_action(self, request, *args, **kwargs):
|
||||||
pass
|
raise NotImplementedError() # pragma: no cover
|
||||||
|
|
||||||
|
|
||||||
router = SimpleRouter()
|
router = SimpleRouter()
|
||||||
|
@ -87,14 +88,13 @@ class InitializeViewSetsTestCase(TestCase):
|
||||||
assert response.status_code == status.HTTP_200_OK
|
assert response.status_code == status.HTTP_200_OK
|
||||||
|
|
||||||
def test_initialize_view_set_with_empty_actions(self):
|
def test_initialize_view_set_with_empty_actions(self):
|
||||||
try:
|
with pytest.raises(TypeError) as excinfo:
|
||||||
BasicViewSet.as_view()
|
BasicViewSet.as_view()
|
||||||
except TypeError as e:
|
|
||||||
assert str(e) == ("The `actions` argument must be provided "
|
assert str(excinfo.value) == (
|
||||||
"when calling `.as_view()` on a ViewSet. "
|
"The `actions` argument must be provided "
|
||||||
"For example `.as_view({'get': 'list'})`")
|
"when calling `.as_view()` on a ViewSet. "
|
||||||
else:
|
"For example `.as_view({'get': 'list'})`")
|
||||||
self.fail("actions must not be empty.")
|
|
||||||
|
|
||||||
def test_args_kwargs_request_action_map_on_self(self):
|
def test_args_kwargs_request_action_map_on_self(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -9,9 +9,6 @@ class WriteOnlyFieldTests(TestCase):
|
||||||
email = serializers.EmailField()
|
email = serializers.EmailField()
|
||||||
password = serializers.CharField(write_only=True)
|
password = serializers.CharField(write_only=True)
|
||||||
|
|
||||||
def create(self, attrs):
|
|
||||||
return attrs
|
|
||||||
|
|
||||||
self.Serializer = ExampleSerializer
|
self.Serializer = ExampleSerializer
|
||||||
|
|
||||||
def test_write_only_fields_are_present_on_input(self):
|
def test_write_only_fields_are_present_on_input(self):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user