aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarlon Bailey2013-05-12 09:22:14 -0400
committerMarlon Bailey2013-05-12 09:22:14 -0400
commit5e2d8052d4bf87c81cc9807c96c933ca975cc483 (patch)
tree44258fd0ca554459303f604206cb5d7a155abf88
parent9d2580dccfe23e113221c7e150bddebb95d98214 (diff)
downloaddjango-rest-framework-5e2d8052d4bf87c81cc9807c96c933ca975cc483.tar.bz2
fix test case to work with Python 3 and make it more explicit
-rw-r--r--rest_framework/tests/routers.py19
1 files changed, 14 insertions, 5 deletions
diff --git a/rest_framework/tests/routers.py b/rest_framework/tests/routers.py
index 138d13d7..4e4765cb 100644
--- a/rest_framework/tests/routers.py
+++ b/rest_framework/tests/routers.py
@@ -38,9 +38,18 @@ class TestSimpleRouter(TestCase):
def test_link_and_action_decorator(self):
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:]
- for i, method in enumerate(['action1', 'action2', 'link1', 'link2']):
- self.assertEqual(decorator_routes[i].mapping.values()[0], method)
+ # Make sure all these endpoints exist and none have been clobbered
+ 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)
+
+