def test_limits_middleware(): # Swallow actions that don't change state middleware = colors.middleware() store = None result = [] actions = [colors.set_user_low(0.0000001), colors.set_user_low(0.0000001)] for action in actions: result += list(middleware(store, action)) assert result == [actions[0]]
({}, colors.set_palette_number(3), { "colorbar": { "number": 3 } }), ({}, colors.set_palette_numbers([1, 2, 3]), { "colorbar": { "numbers": [1, 2, 3] } }), ({}, colors.set_user_high(100), { "colorbar": { "high": 100 } }), ({}, colors.set_user_low(0), { "colorbar": { "low": 0 } }), ({}, colors.set_source_limits(0, 100), { "colorbar": { "low": 0, "high": 100 } }), ]) def test_reducer(state, action, expect): result = colors.reducer(state, action) assert expect == result
def test_limits_reducer_user_low(): number = 42 action = colors.set_user_low(number) state = colors.limits_reducer({}, action) origin = "user" assert state["colorbar"]["limits"][origin]["low"] == number