예제 #1
0
 def test_column_alignment(self):
     """Test controlling column alignment."""
     grid = DataGrid(fields=[
         ('left col', lambda d: d[0]),
         ('center col', lambda d: d[1], dict(align='center')),
         ('right col', lambda d: d[2], dict(align='right'))])
     output = grid.render([('left data', 'center data', 'right data')])
     assert '<td>left data</td><td align="center">center data</td>' \
         '<td align="right">right data</td>' in output
예제 #2
0
 def test_column_alignment(self):
     """Test controlling column alignment."""
     grid = DataGrid(fields=[(
         'left col', lambda d: d[0]
     ), ('center col', lambda d: d[1], dict(
         align='center')), ('right col', lambda d: d[2],
                            dict(align='right'))])
     output = grid.render([('left data', 'center data', 'right data')])
     assert '<td>left data</td><td align="center">center data</td>' \
         '<td align="right">right data</td>' in output
예제 #3
0
 def test_wiki_samples(self):
     """Test that sample code on DataGridWidget wiki page actually works."""
     grid = DataGrid(fields=[
         ('ID', 'userId'),
         ('Name', 'displayName'),
         ('E-mail', 'emailAddress')])
     users = [User(1, 'john', '*****@*****.**'),
         User(2, 'fred', '*****@*****.**')]
     output = grid.render(users)
     assert '<td>2</td><td>Fred</td><td>[email protected]</td>' in output
     grid = DataGrid(fields=[
         ('Name', lambda row: row[1]),
         ('Country', lambda row: row[2]),
         ('Age', lambda row: row[0])])
     data = [(33, "Anton Bykov", "Bulgaria"),
         (23, "Joe Doe", "Great Britain"),
         (44, "Pablo Martelli", "Brazil")]
     output = grid.render(data)
     assert '<td>Joe Doe</td><td>Great Britain</td><td>23</td>' in output
예제 #4
0
 def test_wiki_samples(self):
     """Test that sample code on DataGridWidget wiki page actually works."""
     grid = DataGrid(
         fields=[('ID',
                  'userId'), ('Name',
                              'displayName'), ('E-mail', 'emailAddress')])
     users = [
         User(1, 'john', '*****@*****.**'),
         User(2, 'fred', '*****@*****.**')
     ]
     output = grid.render(users)
     assert '<td>2</td><td>Fred</td><td>[email protected]</td>' in output
     grid = DataGrid(
         fields=[('Name',
                  lambda row: row[1]), (
                      'Country',
                      lambda row: row[2]), ('Age', lambda row: row[0])])
     data = [(33, "Anton Bykov", "Bulgaria"),
             (23, "Joe Doe", "Great Britain"),
             (44, "Pablo Martelli", "Brazil")]
     output = grid.render(data)
     assert '<td>Joe Doe</td><td>Great Britain</td><td>23</td>' in output