Пример #1
0
    def test_row_highlights_reflect_js_selection(self,
                                                 bokeh_model_page) -> None:

        source = ColumnDataSource({'values': [1, 2]})
        col = TableColumn(field='values', title='values')
        table = DataTable(source=source,
                          columns=[col],
                          editable=False,
                          width=600)

        button = ButtonWrapper("Click",
                               callback=CustomJS(args=dict(s=source),
                                                 code="""
            s.selected.indices = [1]
        """))

        page = bokeh_model_page(column(button.obj, table))

        row0 = get_table_cell(page.driver, 1, 1)
        assert 'selected' not in row0.get_attribute('class')

        row1 = get_table_cell(page.driver, 2, 1)
        assert 'selected' not in row1.get_attribute('class')

        button.click(page.driver)

        row0 = get_table_cell(page.driver, 1, 1)
        assert 'selected' not in row0.get_attribute('class')

        row1 = get_table_cell(page.driver, 2, 1)
        assert 'selected' in row1.get_attribute('class')

        assert page.has_no_console_errors()
Пример #2
0
    def test_row_highlights_reflect_js_selection(self, bokeh_model_page):

        source = ColumnDataSource({'values': [1, 2]})
        col = TableColumn(field='values', title='values')
        table = DataTable(source=source, columns=[col], editable=False, width=600)

        button = ButtonWrapper("Click", callback=CustomJS(args=dict(s=source), code="""
            s.selected.indices = [1]
        """))

        page = bokeh_model_page(column(button.obj, table))

        row0 = get_table_cell(page.driver, 1, 1)
        assert 'selected' not in row0.get_attribute('class')

        row1 = get_table_cell(page.driver, 2, 1)
        assert 'selected' not in row1.get_attribute('class')

        button.click(page.driver)

        row0 = get_table_cell(page.driver, 1, 1)
        assert 'selected' not in row0.get_attribute('class')

        row1 = get_table_cell(page.driver, 2, 1)
        assert 'selected' in row1.get_attribute('class')

        assert page.has_no_console_errors()