本文整理汇总了Python中menu.Menu.process方法的典型用法代码示例。如果您正苦于以下问题:Python Menu.process方法的具体用法?Python Menu.process怎么用?Python Menu.process使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类menu.Menu
的用法示例。
在下文中一共展示了Menu.process方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_select_parents
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import process [as 别名]
def test_select_parents(self):
"""
Ensure the MENU_SELECT_PARENTS setting works
"""
settings.MENU_SELECT_PARENTS = False
request = self.factory.get('/parent2/kids2-1')
items = Menu.process(request, 'test')
self.assertEqual(items[0].selected, True)
self.assertEqual(items[0].children[1].selected, True)
self.assertEqual(items[1].selected, False)
request = self.factory.get('/kids2-2')
items = Menu.process(request, 'test')
self.assertEqual(items[0].selected, False)
self.assertEqual(items[0].children[0].selected, True)
self.assertEqual(items[1].selected, False)
settings.MENU_SELECT_PARENTS = True
request = self.factory.get('/kids2-2')
items = Menu.process(request, 'test')
self.assertEqual(items[0].selected, True)
self.assertEqual(items[0].children[0].selected, True)
self.assertEqual(items[1].selected, False)
request = self.factory.get('/parent3/kids3-1/kid1')
items = Menu.process(request, 'test')
self.assertEqual(items[0].selected, False)
self.assertEqual(items[0].children[1].selected, False)
self.assertEqual(items[1].selected, True)
self.assertEqual(items[1].children[0].selected, True)
self.assertEqual(items[1].children[0].children[0].selected, True)
self.assertEqual(items[1].children[1].selected, False)
self.assertEqual(items[2].selected, False)
示例2: test_callable_title
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import process [as 别名]
def test_callable_title(self):
"""
Ensure callable titles work
"""
self.kids3_2_desired_title = "fun"
request = self.factory.get('/parent3')
Menu.process(request, 'test')
self.assertEqual(Menu.items['test'][1].children[1].title, "/parent3-fun")
示例3: test_checks
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import process [as 别名]
def test_checks(self):
"""
Ensure checks on menus work
"""
request = self.factory.get('/kids2-2/visible')
Menu.process(request, 'test')
self.assertEqual(len(Menu.items['test'][0].children), 2)
request = self.factory.get('/kids2-2/hidden')
Menu.process(request, 'test')
self.assertEqual(len(Menu.items['test'][0].children), 1)
示例4: test_custom_menuitem
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import process [as 别名]
def test_custom_menuitem(self):
"""
Ensure our custom check on our custom MenuItem works
"""
request = self.factory.get('/parent3/kids3-1')
items = Menu.process(request, 'test')
self.assertEqual(len(items[1].children), 2)
request = self.factory.get('/parent3/kids3-1/foo')
items = Menu.process(request, 'test')
self.assertEqual(len(items[1].children), 0)
示例5: test_exact_url
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import process [as 别名]
def test_exact_url(self):
"""
Ensure that the exact_url setting works
"""
# the extra stuff will still cause kids3-2 to be selected
request = self.factory.get('/parent3/kids3-2/extra_stuff_here')
Menu.process(request, 'test')
self.assertEqual(Menu.items['test'][1].children[1].selected, True)
# but here it won't, because exact_url is set
request = self.factory.get('/parent3/kids3-1/kid1/extra_stuff_here')
Menu.process(request, 'test')
self.assertEqual(Menu.items['test'][1].children[0].children[0].selected, False)
示例6: test_slug
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import process [as 别名]
def test_slug(self):
"""
Ensure our slugification works as expected
"""
request = self.factory.get('/parent3/kids3-1')
items = Menu.process(request, 'test')
self.assertEqual(items[1].slug, "parent-3")
self.assertEqual(items[1].children[0].slug, "salty")
示例7: home
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import process [as 别名]
def home(request):
Menu.process("main", request)
return render("auth.html", request)
示例8: t2
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import process [as 别名]
def t2(results):
"Closure for thread 2"
request = self.factory.get('/kids2-2/hidden')
items = Menu.process(request, 'test')
results.put_nowait(len(items[0].children) == 1)
示例9: t1
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import process [as 别名]
def t1(results):
"Closure for thread 1"
request = self.factory.get('/kids2-2/visible')
items = Menu.process(request, 'test')
results.put_nowait(len(items[0].children) == 2)