示例#1
0
def test_reducer_on_edit():
    row_index = 0
    layer_index = 42
    action = layers.on_edit(row_index)
    state = layers.reducer({"layers": {"index": {layer_index: {}}}}, action)
    assert state["layers"]["mode"]["index"] == layer_index
    assert state["layers"]["mode"]["state"] == "edit"
示例#2
0
def test_reducer_remove_layer():
    row_index = 0
    layer_index = 42
    state = {"layers": {"index": {layer_index: {"key": "value"}}}}
    action = layers.on_close(row_index)
    state = layers.reducer(state, action)
    assert state["layers"]["index"] == {}
示例#3
0
def test_reducer(state, actions, expect):
    if isinstance(actions, dict):
        actions = [actions]
    for action in actions:
        state = layers.reducer(state, action)
    result = state["layers"]
    assert result == forest.state.State(layers=expect).layers.to_dict()
示例#4
0
def test_reducer_set_active():
    row_index = 1
    active = [0, 2]
    action = layers.set_active(row_index, active)
    state = layers.reducer({"layers": {
        "index": {
            13: {},
            42: {},
            96: {}
        }
    }}, action)
    assert state["layers"]["index"][42]["active"] == active
示例#5
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
示例#6
0
def test_reducer_on_add():
    action = layers.on_add()
    state = layers.reducer({}, action)
    assert state["layers"]["mode"]["state"] == "add"