Exemple #1
0
    def test__with_resolver(self):
        urls = Resolver(((r'^/login/$', object, {}, 'login'),))
        resolver = Resolver((urls,))
        url = list(resolver.resolve())[0]

        self.assertIsInstance(url, tornado.web.url)
        self.assertEqual(url.matcher.regex.pattern, r'^/login/$')
        self.assertEqual(url.name, 'login')
Exemple #2
0
    def test__with_include(self):
        urls = ((r'^/login/$', object, {}, 'login'),)
        resolver = Resolver(((r'^/home/', include(urls, namespace='home')),))
        url = list(resolver.resolve())[0]

        self.assertIsInstance(url, tornado.web.url)
        self.assertEqual(url.matcher.regex.pattern, r'^/home/login/$')
        self.assertEqual(url.name, 'home:login')
Exemple #3
0
    def test(self):
        pattern = (r'^/login/$', object, {'k': 'v'}, 'login')
        resolver = Resolver((pattern,))
        url = list(resolver.resolve())[0]

        self.assertIsInstance(url, tornado.web.url)
        self.assertEqual(url.regex.pattern, pattern[0])
        self.assertEqual(url.handler_class, pattern[1])
        self.assertEqual(url.kwargs, pattern[2])
        self.assertEqual(url.name, pattern[3])
Exemple #4
0
    def test__dict_pattern(self):
        pattern = {
            'pattern': r'^/login/$', 'handler': object,
            'kwargs': {'k': 'v'}, 'name': 'login'
        }
        resolver = Resolver((pattern,))
        url = list(resolver.resolve())[0]

        self.assertIsInstance(url, tornado.web.url)
        self.assertEqual(url.regex.pattern, pattern['pattern'])
        self.assertEqual(url.handler_class, pattern['handler'])
        self.assertEqual(url.kwargs, pattern['kwargs'])
        self.assertEqual(url.name, pattern['name'])
Exemple #5
0
    def test__string_pattern(self):
        unittest.urls = (tornado.web.url(r'^/login/$', object),)
        resolver = Resolver('unittest.urls')

        self.assertEqual(unittest.urls[0], list(resolver.resolve())[0])
Exemple #6
0
    def test__url_pattern(self):
        pattern = tornado.web.url(r'^/login/$', object)
        resolver = Resolver((pattern,))

        self.assertEqual(pattern, list(resolver.resolve())[0])