def test_dynamic_old_style_get_info(self): handler = self.make_handler() route = DynamicRoute('GET', handler, 'name', '<pattern>', '/get/{path}') self.router.register_route(route) self.assertEqual(route.get_info(), {'formatter': '/get/{path}', 'pattern': '<pattern>'})
def test_dynamic_route_match_found(self): route = DynamicRoute('GET', lambda req: None, None, re.compile('/path/(?P<to>.+)'), '/path/{to}') self.router.register_route(route) self.assertEqual({'to': 'to'}, route.match('/path/to'))
def test_dynamic_route_url(self): route = DynamicRoute('GET', lambda req: None, None, '<pattern>', '/{path}') self.router.register_route(route) self.assertEqual('/path?arg=1', route.url(parts={'path': 'path'}, query={'arg': 1}))
def test_dynamic_repr(self): handler = self.make_handler() route = DynamicRoute('GET', handler, 'name', 'pattern', '/get/{path}') self.assertRegex(repr(route), r"<DynamicRoute 'name' \[GET\] /get/{path}")