mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-03-27 13:24:26 +03:00
Add a test for #2583 fix
This commit is contained in:
parent
bdc64d4e73
commit
9cafdd1854
|
@ -302,12 +302,16 @@ class DynamicListAndDetailViewSet(viewsets.ViewSet):
|
||||||
return Response({'method': 'link2'})
|
return Response({'method': 'link2'})
|
||||||
|
|
||||||
|
|
||||||
|
class SubDynamicListAndDetailViewSet(DynamicListAndDetailViewSet):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class TestDynamicListAndDetailRouter(TestCase):
|
class TestDynamicListAndDetailRouter(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.router = SimpleRouter()
|
self.router = SimpleRouter()
|
||||||
|
|
||||||
def test_list_and_detail_route_decorators(self):
|
def _test_list_and_detail_route_decorators(self, viewset):
|
||||||
routes = self.router.get_routes(DynamicListAndDetailViewSet)
|
routes = self.router.get_routes(viewset)
|
||||||
decorator_routes = [r for r in routes if not (r.name.endswith('-list') or r.name.endswith('-detail'))]
|
decorator_routes = [r for r in routes if not (r.name.endswith('-list') or r.name.endswith('-detail'))]
|
||||||
|
|
||||||
MethodNamesMap = namedtuple('MethodNamesMap', 'method_name url_path')
|
MethodNamesMap = namedtuple('MethodNamesMap', 'method_name url_path')
|
||||||
|
@ -336,3 +340,9 @@ class TestDynamicListAndDetailRouter(TestCase):
|
||||||
else:
|
else:
|
||||||
method_map = 'get'
|
method_map = 'get'
|
||||||
self.assertEqual(route.mapping[method_map], method_name)
|
self.assertEqual(route.mapping[method_map], method_name)
|
||||||
|
|
||||||
|
def test_list_and_detail_route_decorators(self):
|
||||||
|
self._test_list_and_detail_route_decorators(DynamicListAndDetailViewSet)
|
||||||
|
|
||||||
|
def test_inherited_list_and_detail_route_decorators(self):
|
||||||
|
self._test_list_and_detail_route_decorators(SubDynamicListAndDetailViewSet)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user