def test_add_events( self, df_type, add_interaction, reset_event, event_1, event_2 ): bg = BaseGraph() bg.add_interaction = add_interaction bg.reset_event = reset_event bg.chart = hv.InteractiveDatashader() df = initialize_df(df_type, {"x": [1, 2, 2], "y": [3, 4, 5]}) dashboard = DashBoard(dataframe=DataFrame.from_dataframe(df)) self.event_1 = None self.event_2 = None def t_func(fn): self.event_1 = fn.__name__ def t_func1(fn): self.event_2 = fn.__name__ bg.chart.add_box_select_callback = t_func bg.chart.add_lasso_select_callback = t_func1 bg.add_events(dashboard) assert self.event_1 == event_1 assert self.event_2 == event_2
def test_view(self, chart, _chart): bg = BaseGraph() bg.chart = mock.Mock(**{"view.return_value": chart}) bg.width = 400 bg.title = "test" assert str(bg.view()) == str( chart_view(_chart, width=bg.width, title=bg.title) )
def test_add_reset_event(self, df_type): bg = BaseGraph() bg.edges = None bg.chart_type = "test" bg.x = "a" bg.x_range = (0, 2) bg.y_range = (3, 5) bg.chart = hv.InteractiveDatashader() df = initialize_df(df_type, {"a": [1, 2, 2], "b": [3, 4, 5]}) dashboard = DashBoard(dataframe=DataFrame.from_dataframe(df)) dashboard._active_view = bg def t_func1(event, fn): fn("event") def reload_fn(data, edges=None, patch_update=False): pass bg.add_event = t_func1 bg.reload_chart = reload_fn bg.add_reset_event(dashboard) assert bg.selected_indices is None
def test_view(self, chart, _chart): bg = BaseGraph() bg.chart = chart bg.width = 400 assert str(bg.view()) == str(chart_view(_chart, width=bg.width))