本文整理匯總了Python中horizon.tabs.TableTab方法的典型用法代碼示例。如果您正苦於以下問題:Python tabs.TableTab方法的具體用法?Python tabs.TableTab怎麽用?Python tabs.TableTab使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類horizon.tabs
的用法示例。
在下文中一共展示了tabs.TableTab方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_table_tabs
# 需要導入模塊: from horizon import tabs [as 別名]
# 或者: from horizon.tabs import TableTab [as 別名]
def test_table_tabs(self):
tab_group = TableTabGroup(self.request)
tabs = tab_group.get_tabs()
# Only one tab, as expected.
self.assertEqual(1, len(tabs))
tab = tabs[0]
# Make sure it's the tab we think it is.
self.assertIsInstance(tab, horizon_tabs.TableTab)
# Data should not be loaded yet.
self.assertFalse(tab._table_data_loaded)
table = tab._tables[MyTable.Meta.name]
self.assertIsInstance(table, MyTable)
# Let's make sure the data *really* isn't loaded yet.
self.assertIsNone(table.data)
# Okay, load the data.
tab.load_table_data()
self.assertTrue(tab._table_data_loaded)
self.assertQuerysetEqual(table.data,
['FakeObject: object_1',
'FakeObject: object_2',
'FakeObject: object_3',
u'FakeObject: öbject_4'],
transform=six.text_type)
context = tab.get_context_data(self.request)
# Make sure our table is loaded into the context correctly
self.assertEqual(table, context['my_table_table'])
# Since we only had one table we should get the shortcut name too.
self.assertEqual(table, context['table'])