本文整理汇总了Python中djblets.datagrid.grids.DataGrid.precompute_objects方法的典型用法代码示例。如果您正苦于以下问题:Python DataGrid.precompute_objects方法的具体用法?Python DataGrid.precompute_objects怎么用?Python DataGrid.precompute_objects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类djblets.datagrid.grids.DataGrid
的用法示例。
在下文中一共展示了DataGrid.precompute_objects方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SandboxTests
# 需要导入模块: from djblets.datagrid.grids import DataGrid [as 别名]
# 或者: from djblets.datagrid.grids.DataGrid import precompute_objects [as 别名]
class SandboxTests(SpyAgency, TestCase):
"""Testing extension sandboxing."""
def setUp(self):
super(SandboxTests, self).setUp()
self.column = SandboxColumn(id='test')
DataGrid.add_column(self.column)
self.factory = RequestFactory()
self.request = self.factory.get('test', {'columns': 'objid'})
self.request.user = User(username='reviewboard', email='',
password='password')
self.datagrid = DataGrid(request=self.request,
queryset=Group.objects.all())
def tearDown(self):
super(SandboxTests, self).tearDown()
DataGrid.remove_column(self.column)
def test_setup_state_columns(self):
"""Testing DataGrid column sandboxing for setup_state"""
self.spy_on(SandboxColumn.setup_state)
self.datagrid.get_stateful_column(column=self.column)
self.assertTrue(SandboxColumn.setup_state.called)
def test_get_sort_field_columns(self):
"""Testing DataGrid column sandboxing for get_sort_field"""
self.datagrid.sort_list = ['test']
self.datagrid.default_columns = ['objid', 'test']
self.spy_on(SandboxColumn.get_sort_field)
self.assertRaisesMessage(
FieldError,
"Invalid order_by arguments: [u'']",
lambda: self.datagrid.precompute_objects())
self.assertTrue(SandboxColumn.get_sort_field.called)
def test_render_data_columns(self):
"""Testing DataGrid column sandboxing for render_data"""
stateful_column = self.datagrid.get_stateful_column(column=self.column)
self.spy_on(SandboxColumn.render_data)
super(SandboxColumn, self.column).render_cell(state=stateful_column,
obj=None,
render_context=None)
self.assertTrue(SandboxColumn.render_data.called)
def test_augment_queryset_columns(self):
"""Testing DataGrid column sandboxing for augment_queryset"""
stateful_column = self.datagrid.get_stateful_column(column=self.column)
self.datagrid.columns.append(stateful_column)
self.spy_on(SandboxColumn.augment_queryset)
self.datagrid.post_process_queryset(queryset=[])
self.assertTrue(SandboxColumn.augment_queryset.called)