示例#1
0
def test_zoomed_parent_goal_must_not_be_filtered_out(zoomed_goaltree):
    zoomed_goaltree.accept_all(HoldSelect(), Select(2), ToggleZoom(),
                               FilterBy("mm"))
    assert zoomed_goaltree.q("name,edge,select") == {
        -1: {
            "name": "Alpha",
            "edge": [(-2, EdgeType.BLOCKER), (2, EdgeType.BLOCKER)],
            "select": "prev",
        },
        -2: {
            "name": "Filter by 'mm'",
            "edge": [(2, EdgeType.BLOCKER), (3, EdgeType.BLOCKER)],
            "select": None,
        },
        2: {
            "name": "Beta",
            "edge": [(3, EdgeType.PARENT)],
            "select": "select"
        },
        3: {
            "name": "Gamma",
            "edge": [],
            "select": None
        },
    }
示例#2
0
文件: cli.py 项目: ahitrin/SiebenApp
def build_actions(command):
    simple_commands = {
        "c": ToggleClose(),
        "d": Delete(),
        "h": HoldSelect(),
        "k": ToggleLink(edge_type=EdgeType.PARENT),
        "l": ToggleLink(),
        "n": ToggleOpenView(),
        "p": ToggleProgress(),
        "t": ToggleSwitchableView(),
        "z": ToggleZoom(),
    }
    if command and all(c in "1234567890" for c in command):
        return [Select(int(c)) for c in command]
    if command.startswith("a "):
        return [Add(command[2:])]
    if command.startswith("i "):
        return [Insert(command[2:])]
    if command.startswith("r "):
        return [Rename(command[2:])]
    if command.startswith("f"):
        return [FilterBy(command[1:].lstrip())]
    if command.startswith("` "):
        return [ToggleAutoLink(command[2:])]
    if command in simple_commands:
        return [simple_commands[command]]
    return []
示例#3
0
def test_how_should_we_deal_with_zooming():
    g = build_goaltree(
        open_(1, "Root", [2]),
        open_(2, "Zoomed", blockers=[3], select=selected),
        open_(3, "Ex-top"),
    )
    v = SwitchableView(persistent_layers(g))
    v.accept_all(ToggleZoom(), ToggleSwitchableView())
    assert v.q("name,select") == {
        2: {
            "name": "Zoomed",
            "select": "select"
        },
        3: {
            "name": "Ex-top",
            "select": None
        },
    }
    v.accept(Add("Unexpectedly hidden"))
    assert v.q("name,select") == {
        2: {
            "name": "Zoomed",
            "select": "select"
        },
        3: {
            "name": "Ex-top",
            "select": None
        },
        4: {
            "name": "Unexpectedly hidden",
            "select": None
        },
    }
示例#4
0
def test_do_not_enumerate_goals_with_negative_id():
    g = all_layers(
        build_goaltree(
            open_(1, "Root", [2]),
            open_(2, "Zoomed", [3], select=selected),
            open_(3, "Top"),
        )
    )
    g.accept(ToggleZoom())
    assert g.q("name,select,edge") == {
        -1: {"name": "Root", "select": None, "edge": [(2, EdgeType.BLOCKER)]},
        2: {"name": "Zoomed", "select": "select", "edge": [(3, EdgeType.PARENT)]},
        3: {"name": "Top", "select": None, "edge": []},
    }
    e = Enumeration(g)
    assert e.q("name,select,edge") == {
        -1: {"name": "Root", "select": None, "edge": [(1, EdgeType.BLOCKER)]},
        1: {"name": "Zoomed", "select": "select", "edge": [(2, EdgeType.PARENT)]},
        2: {"name": "Top", "select": None, "edge": []},
    }
示例#5
0
def test_save_and_load():
    file_name = NamedTemporaryFile().name
    goals = Enumeration(all_layers(Goals("Root")))
    goals.accept_all(
        Add("Top"),
        Add("Middle"),
        Select(3),
        HoldSelect(),
        Select(2),
        ToggleLink(),
        Add("Closed"),
        Select(4),
        ToggleClose(),
        Select(2),
        ToggleZoom(),
    )
    save(goals, file_name)
    new_goals = load(file_name)
    goals.accept_all(ToggleOpenView())
    new_goals.accept_all(ToggleOpenView())
    assert goals.q(keys="open,name,edge,select,switchable") == new_goals.q(
        keys="open,name,edge,select,switchable")
示例#6
0
def test_zoom_after_extract(extract_source, extract_target):
    result = extract_subtree(extract_source, 2)
    result.accept_all(Select(3), ToggleZoom())
    extract_target.accept_all(Select(3), ToggleZoom())
    assert extract_target.q(keys="name,edge,open,selection") == result.q(
        keys="name,edge,open,selection")
示例#7
0
 def toggle_zoom(self):
     self.force_refresh = True
     self.goals.accept(ToggleZoom())
     self.refresh.emit()
示例#8
0
 def zoom(self):
     event("zoom")
     self._accept(ToggleZoom())