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)
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)
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'])
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'])
def test_namespace(self): 'Locations namespace' chain = web.namespace('news') | web.match('/', 'index') self.assert_(web.locations(chain).keys(), ['news.index'])
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'])