Example #1
0
def test_middleware_on_save_given_add():
    mode = "add"
    index = 42
    initial_state = {"layers": {"mode": {"state": mode}, "index": {index: {}}}}
    store = redux.Store(layers.reducer, initial_state=initial_state)
    action = layers.on_save({})
    expect = layers.save_layer(index + 1, {})
    result = list(layers.middleware(store, action))
    assert expect == result[0]
Example #2
0
def test_reducer_save_layer():
    i = 42
    label = "Label"
    dataset = "Dataset"
    variable = "Variable"
    action = layers.save_layer(i, {
        "label": label,
        "dataset": dataset,
        "variable": variable
    })
    state = layers.reducer({}, action)
    assert state["layers"]["index"][i]["label"] == label
    assert state["layers"]["index"][i]["dataset"] == dataset
    assert state["layers"]["index"][i]["variable"] == variable
Example #3
0
def test_middleware_on_save_given_edit():
    mode = "edit"
    index = 5
    initial_state = {
        "layers": {
            "mode": {
                "state": mode,
                "index": index
            },
            "index": {
                0: {}
            }
        }
    }
    store = redux.Store(layers.reducer, initial_state=initial_state)
    action = layers.on_save({})
    expect = [layers.save_layer(index, {})]
    result = list(layers.middleware(store, action))
    assert expect == result