def test_template_overridal(self):
     """Test overriding the template."""
     grid = DataGrid(fields=[('Name', 'name'), ('Subtype', 'subtype'),
                             ('TEXT', Foo._get_excerpt)],
                     template="turbogears.fastdata.templates.datagrid")
     d = dict(value='value')
     grid.update_params(d)
Exemple #2
0
 def test_template_overridal(self):
     grid = DataGrid(fields=[
                 ('Name', 'name'), 
                 ('Subtype', 'subtype'),
                 ('TEXT', Foo._get_excerpt),
             ], template = "turbogears.fastdata.templates.datagrid")
     d = dict(value='value')
     grid.update_params(d)
 def test_template_overridal(self):
     """Test overriding the template."""
     grid = DataGrid(fields=[
             ('Name', 'name'),
             ('Subtype', 'subtype'),
             ('TEXT', Foo.excerpt.fget)],
         template = "turbogears.fastdata.templates.datagrid")
     d = dict(value='value')
     grid.update_params(d)
 def test_column_declaration(self):
     """Test standard column declaration styles."""
     grid = DataGrid(name='grid', fields=[
         DataGrid.Column('name', options=dict(foobar=123)),
         ('Subtype', 'subtype'),
         DataGrid.Column('text', 'excerpt', 'TEXT')])
     d = dict(value='value')
     grid.update_params(d)
     get_field = d['get_field']
     assert d['columns'][0].get_option('foobar') == 123
     assert grid.get_column('name').options['foobar'] == 123
     row = Foo('spa1', 'fact', 'thetext')
     assert 'spa1' == get_field(row, 'name')
     assert 'fact' == get_field(row, 'column-1')
     assert 'thetext...' == get_field(row, 'text')
 def test_column_declaration(self):
     """Test standard column declaration styles."""
     grid = DataGrid(name='grid',
                     fields=[
                         DataGrid.Column('name', options=dict(foobar=123)),
                         ('Subtype', 'subtype'),
                         DataGrid.Column('text', 'excerpt', 'TEXT')
                     ])
     d = dict(value='value')
     grid.update_params(d)
     get_field = d['get_field']
     # 'headers' and 'collist' only supported for backward compatibility
     assert d['headers'] == ['Name', 'Subtype', 'TEXT']
     assert d['collist'] == ['name', 'column-1', 'text']
     assert d['columns'][0].get_option('foobar') == 123
     assert grid.get_column('name').options['foobar'] == 123
     row = Foo('spa1', 'fact', 'thetext')
     assert 'spa1' == get_field(row, 'name')
     assert 'fact' == get_field(row, 'column-1')
     assert 'thetext...' == get_field(row, 'text')