Пример #1
0
 def new_columns(self):
     return [
         StaticColumn(IntegerField(label='Row Number'),
                      'row',
                      sort_key=lambda i: i.row),
         StaticColumn(Field(label='Alpha'),
                      'alpha',
                      sort_key=lambda i: i.alpha),
     ]
Пример #2
0
def test_table_layout_header_options(web_fixture, layout_scenarios):
    """TableLayout can style a table header row."""

    data = [DataItem(1, 'T'), DataItem(2, 'H'), DataItem(3, 'E')]

    column_definitions = [
        StaticColumn(Field(label='Row Number'), 'row'),
        StaticColumn(Field(label='Alpha'), 'alpha')
    ]

    layout = TableLayout(heading_theme=layout_scenarios.theme)
    table = Table(web_fixture.view).with_data(column_definitions, data)
    table.use_layout(layout)

    if layout_scenarios.theme is not None:
        assert layout.widget.thead.get_attribute(
            'class') == '%s' % layout_scenarios.expected_css_class
    else:
        assert not layout.widget.thead.has_attribute('class')
Пример #3
0
def which_columns_can_cause_sorting(fixture):
    """Only columns with sort_key specified are sortable."""

    fixture.columns.append(StaticColumn(Field(label='Not sortable'), 'alpha'))

    fixture.reahl_server.set_app(fixture.wsgi_app)
    fixture.driver_browser.open('/')

    vassert(fixture.does_column_have_sort_link(1))
    vassert(fixture.does_column_have_sort_link(2))
    vassert(not fixture.does_column_have_sort_link(3))
Пример #4
0
def test_which_columns_can_cause_sorting(web_fixture, data_table_fixture):
    """Only columns with sort_key specified are sortable."""

    data_table_fixture.columns.append(
        StaticColumn(Field(label='Not sortable'), 'alpha'))

    web_fixture.reahl_server.set_app(data_table_fixture.wsgi_app)
    browser = web_fixture.driver_browser
    browser.open('/')

    assert data_table_fixture.does_column_have_sort_link(1)
    assert data_table_fixture.does_column_have_sort_link(2)
    assert not data_table_fixture.does_column_have_sort_link(3)