Esempio n. 1
0
def test_ws_when_raise_key_error_for_unset_param():
    pg = PortGraph()
    pg.add_vertex(0)
    pg.add_in_port(0, "in", 0)

    ws = WorkflowState(pg)
    assert_raises(KeyError, lambda: ws.when(0))
Esempio n. 2
0
def test_ws_when_is_none_for_non_evaluated_output_port():
    pg = PortGraph()
    pg.add_vertex(0)
    pg.add_out_port(0, "out", 0)

    ws = WorkflowState(pg)
    assert ws.when(0) is None
Esempio n. 3
0
def test_ws_when_set_explicitly_for_params():
    pg = PortGraph()
    pg.add_vertex(0)
    pg.add_in_port(0, "in", 0)

    ws = WorkflowState(pg)
    ws.store_param(0, "param", 10)
    assert ws.when(0) == 10
Esempio n. 4
0
def test_ws_when_is_last_evaluation_for_output_port():
    pg = PortGraph()
    pg.add_vertex(0)
    pg.add_out_port(0, "out", 0)

    ws = WorkflowState(pg)
    ws.set_last_evaluation(0, 1)
    assert ws.when(0) == 1
Esempio n. 5
0
def test_ws_when_is_none_on_creation():
    pg = PortGraph()
    pg.add_vertex(0)
    pg.add_in_port(0, "in", 0)
    pg.add_out_port(0, "out", 1)

    ws = WorkflowState(pg)
    assert_raises(KeyError, lambda: ws.when(10))
Esempio n. 6
0
def test_ws_when_connected_input_port():
    pg = PortGraph()
    pg.add_vertex(0)
    pg.add_out_port(0, "out", 0)
    pg.add_vertex(1)
    pg.add_out_port(1, "out", 1)
    pg.add_vertex(2)
    pg.add_in_port(2, "in", 2)
    pg.connect(0, 2)

    ws = WorkflowState(pg)
    assert ws.when(2) is None
    ws.set_last_evaluation(0, 10)
    assert ws.when(2) == 10

    pg.connect(1, 2)
    ws = WorkflowState(pg)
    assert ws.when(2) is None
    ws.set_last_evaluation(0, 10)
    assert ws.when(2) is None
    ws.set_last_evaluation(1, 11)
    assert ws.when(2) == 10