当前位置: 首页>>代码示例>>Python>>正文


Python horizon.Panel方法代码示例

本文整理汇总了Python中horizon.Panel方法的典型用法代码示例。如果您正苦于以下问题:Python horizon.Panel方法的具体用法?Python horizon.Panel怎么用?Python horizon.Panel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在horizon的用法示例。


在下文中一共展示了horizon.Panel方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_dashboard

# 需要导入模块: import horizon [as 别名]
# 或者: from horizon import Panel [as 别名]
def test_dashboard(self):
        cats = horizon.get_dashboard("cats")
        self.assertEqual(base.Horizon, cats._registered_with)
        self.assertQuerysetEqual(cats.get_panels(),
                                 ['<Panel: kittens>',
                                  '<Panel: tigers>'])
        self.assertEqual("/cats/", cats.get_absolute_url())
        self.assertEqual("Cats", cats.name)

        # Test registering a module with a dashboard that defines panels
        # as a panel group.
        cats.register(MyPanel)
        self.assertQuerysetEqual(cats.get_panel_groups()['other'],
                                 ['<Panel: myslug>'])

        # Test that panels defined as a tuple still return a PanelGroup
        dogs = horizon.get_dashboard("dogs")
        self.assertQuerysetEqual(dogs.get_panel_groups().values(),
                                 ['<PanelGroup: default>'])

        # Test registering a module with a dashboard that defines panels
        # as a tuple.
        dogs = horizon.get_dashboard("dogs")
        dogs.register(MyPanel)
        self.assertQuerysetEqual(dogs.get_panels(),
                                 ['<Panel: puppies>',
                                  '<Panel: myslug>']) 
开发者ID:CiscoSystems,项目名称:avos,代码行数:29,代码来源:base.py

示例2: test_panel_without_slug_fails

# 需要导入模块: import horizon [as 别名]
# 或者: from horizon import Panel [as 别名]
def test_panel_without_slug_fails(self):
        class InvalidPanel(horizon.Panel):
            name = 'Invalid'

        self.assertRaises(ImproperlyConfigured, InvalidPanel) 
开发者ID:CiscoSystems,项目名称:avos,代码行数:7,代码来源:base.py

示例3: test_customize_dashboard

# 需要导入模块: import horizon [as 别名]
# 或者: from horizon import Panel [as 别名]
def test_customize_dashboard(self):
        cats = horizon.get_dashboard("cats")
        self.assertEqual("WildCats", cats.name)
        self.assertQuerysetEqual(cats.get_panels(),
                                 ['<Panel: kittens>'])
        with self.assertRaises(base.NotRegistered):
            horizon.get_dashboard("dogs") 
开发者ID:CiscoSystems,项目名称:avos,代码行数:9,代码来源:base.py

示例4: test_rbac_panels

# 需要导入模块: import horizon [as 别名]
# 或者: from horizon import Panel [as 别名]
def test_rbac_panels(self):
        context = {'request': self.request}
        cats = horizon.get_dashboard("cats")
        self.assertEqual(cats._registered_with, base.Horizon)
        self.assertQuerysetEqual(cats.get_panels(),
                                 ['<Panel: rbac_panel_no>'])
        self.assertFalse(cats.can_access(context))

        dogs = horizon.get_dashboard("dogs")
        self.assertEqual(dogs._registered_with, base.Horizon)
        self.assertQuerysetEqual(dogs.get_panels(),
                                 ['<Panel: rbac_panel_yes>'])

        self.assertTrue(dogs.can_access(context)) 
开发者ID:CiscoSystems,项目名称:avos,代码行数:16,代码来源:base.py


注:本文中的horizon.Panel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。