Пример #1
0
 def test_mix(self):
     'Loactions mix'
     chain = web.prefix('/items') | web.cases(
         web.match('/', 'index'),
         web.prefix('/news') | web.namespace('news') | web.cases(
             web.match('/', 'index'), web.match('/<int:id>', 'item')),
         web.prefix('/docs') | web.namespace('docs') | web.cases(
             web.match('/', 'index'), web.match('/<int:id>', 'item')))
     locations = web.locations(chain)
     self.assertEqual(
         locations.keys(),
         ['index', 'docs.index', 'docs.item', 'news.item', 'news.index'])
     self.assertEqual(len(locations['index']['builders']), 2)
     self.assertEqual(len(locations['news.index']['builders']), 3)
     self.assertEqual(len(locations['news.item']['builders']), 3)
     self.assertEqual(len(locations['docs.index']['builders']), 3)
     self.assertEqual(len(locations['docs.item']['builders']), 3)
Пример #2
0
 def test_mix(self):
     'Loactions mix'
     chain = web.prefix('/items') | web.cases(
         web.match('/', 'index'),
         web.prefix('/news') | web.namespace('news') | web.cases(
             web.match('/', 'index'),
             web.match('/<int:id>', 'item')),
         web.prefix('/docs') | web.namespace('docs') | web.cases(
             web.match('/', 'index'),
             web.match('/<int:id>', 'item')))
     locations = web.locations(chain)
     self.assertEqual(locations.keys(), 
                      ['index', 'docs.index', 'docs.item',
                       'news.item', 'news.index'])
     self.assertEqual(len(locations['index']['builders']), 2)
     self.assertEqual(len(locations['news.index']['builders']), 3)
     self.assertEqual(len(locations['news.item']['builders']), 3)
     self.assertEqual(len(locations['docs.index']['builders']), 3)
     self.assertEqual(len(locations['docs.item']['builders']), 3)
Пример #3
0
 def test_namespace_with_empty_name(self):
     'Namespaces with empty url name'
     chain = web.namespace('news') | web.match('/', '')
     self.assert_(web.locations(chain).keys(), ['news'])
Пример #4
0
 def test_namespace_and_cases(self):
     'Locations namespace with web.cases'
     chain = web.namespace('news') | web.cases(
             web.match('/', 'index'),
             web.match('/docs', 'docs'))
     self.assertEqual(web.locations(chain).keys(), ['news.index', 'news.docs'])
Пример #5
0
 def test_namespace(self):
     'Locations namespace'
     chain = web.namespace('news') | web.match('/', 'index')
     self.assert_(web.locations(chain).keys(), ['news.index'])
Пример #6
0
 def test_namespace_with_empty_name(self):
     'Namespaces with empty url name'
     chain = web.namespace('news') | web.match('/', '')
     self.assert_(web.locations(chain).keys(), ['news'])
Пример #7
0
 def test_namespace_and_cases(self):
     'Locations namespace with web.cases'
     chain = web.namespace('news') | web.cases(web.match('/', 'index'),
                                               web.match('/docs', 'docs'))
     self.assertEqual(
         web.locations(chain).keys(), ['news.index', 'news.docs'])
Пример #8
0
 def test_namespace(self):
     'Locations namespace'
     chain = web.namespace('news') | web.match('/', 'index')
     self.assert_(web.locations(chain).keys(), ['news.index'])