Пример #1
0
def test_cursor_usage_to_add_a_chain():
    a, b, c = get_pseudo_nodes(*"abc")

    g = Graph()

    g.get_cursor() >> a >> b >> c

    assert len(g) == 3
    assert g.outputs_of(BEGIN) == {g.index_of(a)}
    assert g.outputs_of(a) == {g.index_of(b)}
    assert g.outputs_of(b) == {g.index_of(c)}
    assert g.outputs_of(c) == set()
Пример #2
0
def test_cursor_to_fork_a_graph():
    a, b, c, d, e = get_pseudo_nodes(*"abcde")

    g = Graph()
    g >> a >> b >> c
    g.get_cursor(b) >> d >> e

    assert len(g) == 5
    assert g.outputs_of(BEGIN) == {g.index_of(a)}
    assert g.outputs_of(a) == {g.index_of(b)}
    assert g.outputs_of(b) == {g.index_of(c), g.index_of(d)}
    assert g.outputs_of(c) == set()
    assert g.outputs_of(d) == {g.index_of(e)}
    assert g.outputs_of(e) == set()
Пример #3
0
def test_get_cursor():
    g = Graph()
    cursor = g.get_cursor()

    assert cursor.graph is g
    assert cursor.first is BEGIN
    assert cursor.last is BEGIN
Пример #4
0
def test_get_cursor_in_a_vacuum():
    g = Graph()
    cursor = g.get_cursor(None)

    assert cursor.graph is g
    assert cursor.first is None
    assert cursor.last is None