Skip to content

Commit 2448cc8

Browse files
committed
Updated tests to use url_path attribute in list and detail decorators
1 parent 92ebeaa commit 2448cc8

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

tests/test_routers.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -261,11 +261,11 @@ def list_route_get(self, request, *args, **kwargs):
261261
def detail_route_get(self, request, *args, **kwargs):
262262
return Response({'method': 'link2'})
263263

264-
@list_route(custom_method_name="list_custom-route")
264+
@list_route(url_path="list_custom-route")
265265
def list_custom_route_get(self, request, *args, **kwargs):
266266
return Response({'method': 'link1'})
267267

268-
@detail_route(custom_method_name="detail_custom-route")
268+
@detail_route(url_path="detail_custom-route")
269269
def detail_custom_route_get(self, request, *args, **kwargs):
270270
return Response({'method': 'link2'})
271271

@@ -278,7 +278,7 @@ def test_list_and_detail_route_decorators(self):
278278
routes = self.router.get_routes(DynamicListAndDetailViewSet)
279279
decorator_routes = [r for r in routes if not (r.name.endswith('-list') or r.name.endswith('-detail'))]
280280

281-
MethodNamesMap = namedtuple('MethodNamesMap', 'method_name custom_method_name')
281+
MethodNamesMap = namedtuple('MethodNamesMap', 'method_name url_path')
282282
# Make sure all these endpoints exist and none have been clobbered
283283
for i, endpoint in enumerate([MethodNamesMap('list_custom_route_get', 'list_custom-route'),
284284
MethodNamesMap('list_route_get', 'list_route_get'),
@@ -290,14 +290,14 @@ def test_list_and_detail_route_decorators(self):
290290
route = decorator_routes[i]
291291
# check url listing
292292
method_name = endpoint.method_name
293-
custom_method_name = endpoint.custom_method_name
293+
url_path = endpoint.url_path
294294

295295
if method_name.startswith('list_'):
296296
self.assertEqual(route.url,
297-
'^{{prefix}}/{0}{{trailing_slash}}$'.format(custom_method_name))
297+
'^{{prefix}}/{0}{{trailing_slash}}$'.format(url_path))
298298
else:
299299
self.assertEqual(route.url,
300-
'^{{prefix}}/{{lookup}}/{0}{{trailing_slash}}$'.format(custom_method_name))
300+
'^{{prefix}}/{{lookup}}/{0}{{trailing_slash}}$'.format(url_path))
301301
# check method to function mapping
302302
if method_name.endswith('_post'):
303303
method_map = 'post'

0 commit comments

Comments
 (0)