mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-13 17:52:36 +03:00
fix test case to work with Python 3 and make it more explicit
This commit is contained in:
parent
9d2580dccf
commit
5e2d8052d4
|
@ -38,9 +38,18 @@ class TestSimpleRouter(TestCase):
|
||||||
|
|
||||||
def test_link_and_action_decorator(self):
|
def test_link_and_action_decorator(self):
|
||||||
routes = self.router.get_routes(BasicViewSet)
|
routes = self.router.get_routes(BasicViewSet)
|
||||||
# Should be 2 by default, and then four from the @action and @link combined
|
|
||||||
#self.assertEqual(len(routes), 6)
|
|
||||||
#
|
|
||||||
decorator_routes = routes[2:]
|
decorator_routes = routes[2:]
|
||||||
for i, method in enumerate(['action1', 'action2', 'link1', 'link2']):
|
# Make sure all these endpoints exist and none have been clobbered
|
||||||
self.assertEqual(decorator_routes[i].mapping.values()[0], method)
|
for i, endpoint in enumerate(['action1', 'action2', 'link1', 'link2']):
|
||||||
|
route = decorator_routes[i]
|
||||||
|
# check url listing
|
||||||
|
self.assertEqual(route.url,
|
||||||
|
'^{{prefix}}/{{lookup}}/{0}/$'.format(endpoint))
|
||||||
|
# check method to function mapping
|
||||||
|
if endpoint.startswith('action'):
|
||||||
|
method_map = 'post'
|
||||||
|
else:
|
||||||
|
method_map = 'get'
|
||||||
|
self.assertEqual(route.mapping[method_map], endpoint)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user