def test_series_on_tap_emits_action(): x, y = 1, 2 # different values to assert order listener = unittest.mock.Mock() figure = bokeh.plotting.figure() event = bokeh.events.Tap(figure, x=x, y=y) view = series.SeriesView(figure, {}) view.subscribe(listener) view.on_tap(event) listener.assert_called_once_with(series.set_position(x, y))
def test_series_reducer(): state = series.reducer({}, series.set_position(0, 0)) assert state == {"position": {"x": 0, "y": 0}}
def test_series_set_position_action(): action = series.set_position(0, 0) assert action == {"kind": series.SET_POSITION, "payload": {"x": 0, "y": 0}}
def test_series_reducer_immutable_state(): state = {"position": {"x": 1, "y": 1}} next_state = series.reducer(state, series.set_position(0, 0)) assert state == {"position": {"x": 1, "y": 1}} assert next_state == {"position": {"x": 0, "y": 0}}
def test_series_reducer(): state = series.reducer({}, series.set_position(0, 0)) assert state == {"position": {"x": 0, "y": 0}} def test_series_reducer_immutable_state(): state = {"position": {"x": 1, "y": 1}} next_state = series.reducer(state, series.set_position(0, 0)) assert state == {"position": {"x": 1, "y": 1}} assert next_state == {"position": {"x": 0, "y": 0}} @pytest.mark.parametrize("actions,expect", [ ([], {}), ([series.set_position(0, 0)], { "position": { "x": 0, "y": 0 } }), ([db.set_value("key", "value")], { "key": "value" }), ([series.set_position(0, 0), db.set_value("key", "value")], { "key": "value", "position": { "x": 0, "y": 0 }