コード例 #1
0
def test_select_goal_by_full_id(goal_chain_11):
    e = Enumeration(goal_chain_11)
    assert e.q(keys="name,select") == {
        11: {"name": "a", "select": "select"},
        12: {"name": "b", "select": None},
        13: {"name": "c", "select": None},
        14: {"name": "d", "select": None},
        15: {"name": "e", "select": None},
        16: {"name": "f", "select": None},
        17: {"name": "g", "select": None},
        18: {"name": "h", "select": None},
        19: {"name": "i", "select": None},
        10: {"name": "j", "select": None},
        21: {"name": "k", "select": None},
    }
    e.accept(Select(13))
    assert e.q(keys="name,select") == {
        11: {"name": "a", "select": "prev"},
        12: {"name": "b", "select": None},
        13: {"name": "c", "select": "select"},
        14: {"name": "d", "select": None},
        15: {"name": "e", "select": None},
        16: {"name": "f", "select": None},
        17: {"name": "g", "select": None},
        18: {"name": "h", "select": None},
        19: {"name": "i", "select": None},
        10: {"name": "j", "select": None},
        21: {"name": "k", "select": None},
    }
コード例 #2
0
def test_render_in_switchable_view():
    goals = build_goaltree(
        open_(1, "Uno", [2, 3, 4, 5, 6]),
        open_(2, "Dos"),
        open_(3, "Tres"),
        open_(4, "Quatro"),
        open_(5, "Cinco"),
        open_(6, "Sext", select=selected),
    )
    view = Enumeration(SwitchableView(goals))
    view.accept(ToggleSwitchableView())
    result = Renderer(view).build().graph
    # Just verify that it renders fine
    assert len(result) == 5
コード例 #3
0
def test_use_mapping_in_selection(goal_chain_10):
    e = Enumeration(goal_chain_10)
    e.accept(Select(0))
    assert e.q(keys="name,select") == {
        1: {"name": "a", "select": "prev"},
        2: {"name": "b", "select": None},
        3: {"name": "c", "select": None},
        4: {"name": "d", "select": None},
        5: {"name": "e", "select": None},
        6: {"name": "f", "select": None},
        7: {"name": "g", "select": None},
        8: {"name": "h", "select": None},
        9: {"name": "i", "select": None},
        0: {"name": "j", "select": "select"},
    }
コード例 #4
0
def test_selection_cache_should_avoid_overflow(goal_chain_11):
    e = Enumeration(goal_chain_11)
    assert e.q(keys="select")[11] == {"select": "select"}
    e.accept(Select(5))
    assert e.q(keys="select")[11] == {"select": "select"}
    e.accept(Select(1))
    assert e.q(keys="select")[11] == {"select": "select"}
    assert e.q(keys="select")[14] == {"select": None}
    e.accept(Select(4))
    assert e.q(keys="select")[11] == {"select": "prev"}
    assert e.q(keys="select")[14] == {"select": "select"}
コード例 #5
0
def test_selection_cache_should_be_reset_after_view_switch(goal_chain_11):
    e = Enumeration(SwitchableView(goal_chain_11))
    e.accept_all(Add("Also top"))
    e.accept(Select(1))
    # Select(1) is kept in a cache and not applied yet
    e.accept(ToggleSwitchableView())
    assert e.q("name,select") == {
        1: {"name": "a", "select": "select"},
        2: {"name": "k", "select": None},
        3: {"name": "Also top", "select": None},
    }
    # Select(2) is being applied without any effect from the previous selection
    # This happens because selection cache was reset
    e.accept(Select(2))
    assert e.q("name,select") == {
        1: {"name": "a", "select": "prev"},
        2: {"name": "k", "select": "select"},
        3: {"name": "Also top", "select": None},
    }