Beispiel #1
0
    def test_multi_row_copy(self, bokeh_model_page) -> None:
        data = {'x': [1,2,3,4], 'y': [0,1,2,3], 'd': ['foo', 'bar', 'baz', 'quux']}
        source = ColumnDataSource(data)
        table = DataTable(columns=[
            TableColumn(field="x", title="x"),
            TableColumn(field="y", title="y"),
            TableColumn(field="d", title="d"),
        ], source=source)

        text_input = TextInput(css_classes=["foo"])
        text_input.js_on_change('value', CustomJS(code=RECORD("value", "cb_obj.value")))

        page = bokeh_model_page(column(table, text_input))

        row = get_table_row(page.driver, 1)
        row.click()

        row = get_table_row(page.driver, 3)
        shift_click(page.driver, row)

        enter_text_in_element(page.driver, row, Keys.INSERT, mod=Keys.CONTROL, click=0, enter=False)

        input_el = page.driver.find_element_by_css_selector('.foo')
        enter_text_in_element(page.driver, input_el, Keys.INSERT, mod=Keys.SHIFT, enter=False)
        enter_text_in_element(page.driver, input_el, "")

        results = page.results

        # XXX (bev) these should be newlines with a TextAreaInput but TextAreaInput
        # is not working in tests for some reason presently
        assert results['value'] == '0\t1\t0\tfoo 1\t2\t1\tbar 2\t3\t2\tbaz'

        assert page.has_no_console_errors()
Beispiel #2
0
    def test_multi_row_copy(self, bokeh_model_page):
        data = {'x': [1,2,3,4], 'y': [0, 1, 2, 3], 'd': ['foo', 'bar', 'baz', 'quux']}
        source = ColumnDataSource(data)
        table = DataTable(columns=[
            TableColumn(field="x", title="x"),
            TableColumn(field="y", title="y"),
            TableColumn(field="d", title="d"),
        ], source=source)

        text_input = TextAreaInput(css_classes=["foo"])
        text_input.js_on_change('value', CustomJS(code=RECORD("value", "cb_obj.value")))

        page = bokeh_model_page(column(table, text_input))

        # select the third row
        row = get_table_row(page.driver, 1)
        row.click()

        row = get_table_row(page.driver, 3)
        shift_click(page.driver, row)

        enter_text_in_element(page.driver, row, Keys.INSERT, mod=Keys.CONTROL, click=0, enter=False)

        input_el = page.driver.find_element_by_css_selector('.foo')
        enter_text_in_element(page.driver, input_el, Keys.INSERT, mod=Keys.SHIFT, enter=False)
        #enter_text_in_element(page.driver, input_el, "")

        sleep(2.0)
        results = page.results

        assert results['value'] == '0\t1\t0\tfoo\n1\t2\t1\tbar\n2\t3\t2\tbaz\n'

        assert page.has_no_console_errors()
Beispiel #3
0
    def test_server_basic_mulitselection(self, bokeh_server_page) -> None:
        data = {'x': [1, 2, 3, 4, 5, 6], 'y': [60, 50, 40, 30, 20, 10]}
        source = ColumnDataSource(data)

        def modify_doc(doc):

            plot = Plot(plot_height=400,
                        plot_width=400,
                        x_range=Range1d(0, 1),
                        y_range=Range1d(0, 1),
                        min_border=0)
            plot.add_tools(
                CustomAction(callback=CustomJS(
                    args=dict(s=source),
                    code=RECORD("indices", "s.selected.indices"))))

            table = DataTable(
                columns=[TableColumn(field="x"),
                         TableColumn(field="y")],
                source=source,
                editable=False)

            doc.add_root(column(plot, table))

        page = bokeh_server_page(modify_doc)

        page.click_custom_action()

        results = page.results
        assert results == {'indices': []}
        assert set(source.selected.indices) == set([])
        assert get_table_selected_rows(page.driver) == set([])

        # select the third row
        row = get_table_row(page.driver, 2)
        row.click()

        row = get_table_row(page.driver, 4)
        shift_click(page.driver, row)

        page.click_custom_action()

        results = page.results
        assert set(results['indices']) == set([1, 2, 3])
        assert set(source.selected.indices) == set([1, 2, 3])
        assert get_table_selected_rows(page.driver) == set([1, 2, 3])

        row = get_table_row(page.driver, 6)
        alt_click(page.driver, row)

        page.click_custom_action()

        results = page.results
        assert set(results['indices']) == set([1, 2, 3, 5])
        assert set(source.selected.indices) == set([1, 2, 3, 5])
        assert get_table_selected_rows(page.driver) == set([1, 2, 3, 5])
Beispiel #4
0
    def test_server_basic_mulitselection(
            self, bokeh_server_page: BokehServerPage) -> None:
        data = {'x': [1, 2, 3, 4, 5, 6], 'y': [60, 50, 40, 30, 20, 10]}
        source = ColumnDataSource(data)

        table = DataTable(
            columns=[TableColumn(field="x"),
                     TableColumn(field="y")],
            source=source,
            editable=False)

        def modify_doc(doc):
            plot = Plot(height=400,
                        width=400,
                        x_range=Range1d(0, 1),
                        y_range=Range1d(0, 1),
                        min_border=0)
            plot.tags.append(
                CustomJS(name="custom-action",
                         args=dict(s=source),
                         code=RECORD("indices", "s.selected.indices")))

            doc.add_root(column(plot, table))

        page = bokeh_server_page(modify_doc)

        page.eval_custom_action()

        results = page.results
        assert results == {'indices': []}
        assert set(source.selected.indices) == set()
        assert get_table_selected_rows(page.driver, table) == set()

        # select the third row
        row = get_table_row(page.driver, table, 2)
        row.click()

        row = get_table_row(page.driver, table, 4)
        shift_click(page.driver, row)

        page.eval_custom_action()

        results = page.results
        assert set(results["indices"]) == {1, 2, 3}
        assert set(source.selected.indices) == {1, 2, 3}
        assert get_table_selected_rows(page.driver, table) == {1, 2, 3}

        row = get_table_row(page.driver, table, 6)
        alt_click(page.driver, row)

        page.eval_custom_action()

        results = page.results
        assert set(results["indices"]) == {1, 2, 3, 5}
        assert set(source.selected.indices) == {1, 2, 3, 5}
        assert get_table_selected_rows(page.driver, table) == {1, 2, 3, 5}
    def test_server_basic_mulitselection(self, bokeh_server_page):
        data = {'x': [1,2,3,4,5,6], 'y': [60,50,40,30,20,10]}
        source = ColumnDataSource(data)

        def modify_doc(doc):

            plot = Plot(plot_height=400, plot_width=400, x_range=Range1d(0, 1), y_range=Range1d(0, 1), min_border=0)
            plot.add_tools(CustomAction(callback=CustomJS(args=dict(s=source), code=RECORD("indices", "s.selected.indices"))))

            table = DataTable(columns=[
                TableColumn(field="x"),
                TableColumn(field="y")
            ], source=source, editable=False)

            doc.add_root(column(plot, table))

        page = bokeh_server_page(modify_doc)

        page.click_custom_action()

        results = page.results
        assert results ==  {'indices': []}
        assert set(source.selected.indices) == set([])
        assert get_table_selected_rows(page.driver) == set([])

        # select the third row
        row = get_table_row(page.driver, 2)
        row.click()

        row = get_table_row(page.driver, 4)
        shift_click(page.driver, row)

        page.click_custom_action()

        results = page.results
        assert set(results['indices']) ==  set([1, 2, 3])
        assert set(source.selected.indices) == set([1, 2, 3])
        assert get_table_selected_rows(page.driver) == set([1, 2, 3])

        row = get_table_row(page.driver, 6)
        alt_click(page.driver, row)

        page.click_custom_action()

        results = page.results
        assert set(results['indices']) ==  set([1, 2, 3, 5])
        assert set(source.selected.indices) == set([1, 2, 3, 5])
        assert get_table_selected_rows(page.driver) == set([1, 2, 3, 5])
Beispiel #6
0
    def test_single_row_copy_with_zero(self, bokeh_model_page) -> None:
        data = {'x': [1,2,3,4], 'y': [0,0,0,0], 'd': ['foo', 'bar', 'baz', 'quux']}
        source = ColumnDataSource(data)
        table = DataTable(columns=[
            TableColumn(field="x", title="x"),
            TableColumn(field="y", title="y"),
            TableColumn(field="d", title="d"),
        ], source=source)

        text_input = TextInput(css_classes=["foo"])
        text_input.js_on_change('value', CustomJS(code=RECORD("value", "cb_obj.value")))

        page = bokeh_model_page(column(table, text_input))

        row = get_table_row(page.driver, 2)
        row.click()

        enter_text_in_element(page.driver, row, Keys.INSERT, mod=Keys.CONTROL, click=0, enter=False)

        input_el = page.driver.find_element_by_css_selector('.foo')
        enter_text_in_element(page.driver, input_el, Keys.INSERT, mod=Keys.SHIFT, enter=False)
        enter_text_in_element(page.driver, input_el, "")

        sleep(0.5)
        results = page.results

        assert results['value'] == '1\t2\t0\tbar'

        assert page.has_no_console_errors()