示例#1
0
    def test_initiate_chart(self):
        bl = BaseLine(x="key", y="val")
        bl.initiate_chart(self.dashboard)

        assert bl.min_value == 0.0
        assert bl.max_value == 4.0
        assert bl.data_points == 5
        assert bl.stride == 1
        assert bl.stride_type == int
示例#2
0
    def test_add_reset_event(self):
        bl = BaseLine(x="key", y="val")
        self.result = None

        def test_func(event, callback):
            self.result = callback

        bl.add_event = test_func
        # test the following function behavior
        bl.add_reset_event(self.dashboard)
        assert self.result.__name__ == "reset_callback"
    def test_compute_query_dict(self, range, query):
        bl = BaseLine(x="key", y="val")
        bl.min_value = self.dashboard._data[bl.x].min()
        bl.max_value = self.dashboard._data[bl.x].max()
        bl.stride = 1
        if bl.data_points > self.dashboard._data[bl.x].shape[0]:
            bl.data_points = self.dashboard._data[bl.x].shape[0]
        bl.add_range_slider_filter(self.dashboard)
        self.dashboard.add_charts([bl])
        bl.filter_widget.value = range
        # test the following function behavior
        bl.compute_query_dict(self.dashboard._query_str_dict)

        assert self.dashboard._query_str_dict["key_line"] == query
示例#4
0
    def test_add_range_slider_filter(self):
        bl = BaseLine(x="key", y="val")
        bl.min_value = self.dashboard._cuxfilter_df.data[bl.x].min()
        bl.max_value = self.dashboard._cuxfilter_df.data[bl.x].max()
        if bl.data_points > self.dashboard._cuxfilter_df.data[bl.x].shape[0]:
            bl.data_points = self.dashboard._cuxfilter_df.data[bl.x].shape[0]
        bl.compute_stride()
        bl.add_range_slider_filter(self.dashboard)

        assert isinstance(bl.filter_widget, pn.widgets.RangeSlider)
        assert bl.filter_widget.value == (0, 4)
    def test_compute_query_dict(self, range, query, local_dict):
        bb = BaseLine(x="key", y="val", title="custom_title")
        bb.chart_type = "non_aggregate_line"
        self.dashboard.add_charts([bb])
        bb.filter_widget.value = range
        # test the following function behavior
        bb.compute_query_dict(
            self.dashboard._query_str_dict,
            self.dashboard._query_local_variables_dict,
        )

        assert (self.dashboard._query_str_dict[
            "key_val_non_aggregate_line_custom_title"] == query)
        for key in local_dict:
            assert (self.dashboard._query_local_variables_dict[key] ==
                    local_dict[key])
    def test_add_range_slider_filter(self):
        bl = BaseLine(x="key", y="val")
        bl.min_value = self.dashboard._data[bl.x].min()
        bl.max_value = self.dashboard._data[bl.x].max()
        if bl.data_points > self.dashboard._data[bl.x].shape[0]:
            bl.data_points = self.dashboard._data[bl.x].shape[0]
        bl.add_range_slider_filter(self.dashboard)

        assert type(bl.filter_widget) == pn.widgets.RangeSlider
        assert bl.filter_widget.value == (0, 4)
示例#7
0
 def test_variables(self):
     bl = BaseLine(x="test_x", y="test_y", color="#8735fb")
     assert bl.x == "test_x"
     assert bl.y == "test_y"
     assert bl.filter_widget is None
     assert bl.stride is None
     assert bl.stride_type == int
     assert bl.width == 800
     assert bl.height == 400
     assert bl.pixel_shade_type == "linear"
     assert bl.color == "#8735fb"
     assert bl.library_specific_params == {}
     assert bl.data_points == 100
     assert bl.add_interaction is True
     assert bl.chart_type is None
    def test_add_events(self, dashboard, event, result):
        bl = BaseLine(x="key", y="val")
        bl.chart = hv.InteractiveDatashader()
        self.result = None

        def test_func(cls):
            self.result = "func_Called"

        bl.add_reset_event = test_func
        bl.reset_event = event
        # test the following function behavior
        bl.add_events(dashboard)

        assert self.result == result
    def test_compute_query_dict(self, dashboard, x_range, y_range, query,
                                local_dict):
        bl = BaseLine(x="x", y="y", title="custom_title")
        bl.chart_type = "non_aggregate_line"
        bl.box_selected_range = local_dict
        bl.chart = hv.InteractiveDatashader()
        bl.x_range = x_range
        bl.y_range = y_range

        dashboard.add_charts([bl])
        # test the following function behavior
        bl.compute_query_dict(
            dashboard._query_str_dict,
            dashboard._query_local_variables_dict,
        )

        assert (
            dashboard._query_str_dict["x_y_non_aggregate_line_custom_title"] ==
            query)
        for key in local_dict:
            assert (
                dashboard._query_local_variables_dict[key] == local_dict[key])
    def test_add_reset_event(self, dashboard):
        bl = BaseLine(x="key", y="val")
        bl.chart = hv.InteractiveDatashader()
        self.result = None

        def test_func(event, callback):
            self.result = callback

        bl.add_event = test_func
        # test the following function behavior
        bl.add_reset_event(dashboard)
        assert bl.selected_indices is None
示例#11
0
    def test_add_events(self, event, result):
        bl = BaseLine(x="key", y="val")
        self.result = None

        def test_func(cls):
            self.result = "func_Called"

        bl.add_reset_event = test_func
        bl.reset_event = event
        # test the following function behavior
        bl.add_events(self.dashboard)

        assert self.result == result
示例#12
0
    def test_view(self, chart, _chart):
        bl = BaseLine(x="test_x", y="test_y")
        bl.chart = chart
        bl.width = 400

        assert str(bl.view()) == str(chart_view(_chart, width=bl.width))
    def test_view(self, chart, _chart):
        bl = BaseLine(x="test_x", y="test_y")
        bl.chart = mock.Mock(**{"view.return_value": chart})
        bl.width = 400

        assert str(bl.view()) == str(chart_view(_chart, width=bl.width))