Exemplo n.º 1
0
 def decorator(func):
     """
     See the pyroutes.route-docstring
     """
     if path in __request__handlers__:
         raise ValueError("Tried to redefine handler for %s with %s" % \
                 (path, func))
     route_instance = Route(func, path, *args, **kwargs)
     __request__handlers__[path] = route_instance
     return route_instance
Exemplo n.º 2
0
    def testExtractUrlParams(self):
        route = Route(_pass, '/foo')
        env = {'PATH_INFO': '/foo/foo/faz'}
        def test(req, bar, baz):
            pass
        self.assertEquals(route.extract_url_params(env), ['foo', 'faz'])

        route_instance = Route(_pass, '/')
        env = {'PATH_INFO': '/foo/foo'}
        self.assertEquals(route_instance.extract_url_params(env), ['foo', 'foo'])


        route_instance = Route(_pass, '/xim')
        env = {'PATH_INFO': '/xim/foo/bar'}
        self.assertEquals(route.extract_url_params(env), ['foo', 'bar'])
Exemplo n.º 3
0
 def testExtractUrlParams(self):
     route = Route(_pass, '/foo')
     env = {'PATH_INFO': '/foo/foo/faz'}
     def test(req, bar, baz):
         pass
     self.assertEquals(route.extract_url_params(test, env), {'bar': 'foo', 'baz': 'faz'})
Exemplo n.º 4
0
 def testName(self):
     route = Route(_pass, '/foo')
     self.assertEquals(_pass.__name__, route.__name__)
Exemplo n.º 5
0
 def testRepr(self):
     route = Route(_pass, '/foo')
     self.assertEquals(repr(route), u'Route(_pass, /foo)')
Exemplo n.º 6
0
 def testInit(self):
     route = Route(_pass, '/foo')
     self.assertEquals(route.handler, _pass)
     self.assertEquals(route.path, '/foo')