當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。