示例#1
0
def test_set_output_pushes_value_to_connected_input():
    """OutPlugs push their values to their connected input plugs."""
    n1 = NodeForTesting()
    n2 = NodeForTesting()
    out_plug = OutputPlug('out', n1)
    in_plug = InputPlug('in', n2)

    out_compound_plug = OutputPlug('out_compound', n1)
    in_compound_plug = InputPlug('in_compound', n2)

    out_plug.value = 'OldValue'
    assert in_plug.value != out_plug.value

    out_plug >> in_plug
    in_plug.is_dirty = False
    assert in_plug.value == out_plug.value
    assert not in_plug.is_dirty

    out_plug.value = 'NewValue'
    assert in_plug.is_dirty
    assert in_plug.value == out_plug.value

    out_compound_plug.value = 'OldValue'
    assert in_compound_plug.value != out_compound_plug.value

    out_compound_plug >> in_compound_plug
    in_compound_plug.is_dirty = False
    assert in_compound_plug.value == out_compound_plug.value
    assert not in_compound_plug.is_dirty

    out_compound_plug.value = 'NewValue'
    assert in_compound_plug.is_dirty
    assert in_compound_plug.value == out_compound_plug.value
示例#2
0
def test_set_output_pushes_value_to_connected_input(clear_default_graph):
    """OutPlugs push their values to their connected input plugs."""
    n1 = NodeForTesting(name="n1")
    n2 = NodeForTesting(name="n2")
    out_plug = OutputPlug("out", n1)
    in_plug = InputPlug("in", n2)

    out_compound_plug = OutputPlug("out_compound", n1)
    in_compound_plug = InputPlug("in_compound", n2)

    out_plug.value = "OldValue"
    assert in_plug.value != out_plug.value

    out_plug >> in_plug
    in_plug.is_dirty = False
    assert in_plug.value == out_plug.value
    assert not in_plug.is_dirty

    out_plug.value = "NewValue"
    assert in_plug.is_dirty
    assert in_plug.value == out_plug.value

    out_compound_plug.value = "OldValue"
    assert in_compound_plug.value != out_compound_plug.value

    out_compound_plug >> in_compound_plug
    in_compound_plug.is_dirty = False
    assert in_compound_plug.value == out_compound_plug.value
    assert not in_compound_plug.is_dirty

    out_compound_plug.value = "NewValue"
    assert in_compound_plug.is_dirty
    assert in_compound_plug.value == out_compound_plug.value
示例#3
0
def test_change_connections_sets_plug_dirty():
    """Connecting and disconnecting sets the plug dirty."""
    n1 = NodeForTesting()
    n2 = NodeForTesting()
    out_plug = OutputPlug('in', n1)
    in_plug = InputPlug('in', n2)

    in_plug.is_dirty = False
    out_plug >> in_plug
    assert in_plug.is_dirty

    in_plug.is_dirty = False
    out_plug << in_plug
    assert in_plug.is_dirty
示例#4
0
def test_set_value_sets_plug_dirty(clear_default_graph):
    """Connecting and disconnecting sets the plug dirty."""
    n = NodeForTesting()
    in_plug = InputPlug("in", n)
    in_compound_plug = InputPlug("in_compound", n)

    in_plug.is_dirty = False
    assert not in_plug.is_dirty
    in_plug.value = "NewValue"
    assert in_plug.is_dirty

    in_compound_plug.is_dirty = False
    assert not in_compound_plug.is_dirty
    in_compound_plug.value = "NewValue"
    assert in_compound_plug.is_dirty
示例#5
0
def test_set_value_sets_plug_dirty():
    """Connecting and disconnecting sets the plug dirty."""
    n = NodeForTesting()
    in_plug = InputPlug('in', n)
    in_compound_plug = InputPlug('in_compound', n)

    in_plug.is_dirty = False
    assert not in_plug.is_dirty
    in_plug.value = 'NewValue'
    assert in_plug.is_dirty

    in_compound_plug.is_dirty = False
    assert not in_compound_plug.is_dirty
    in_compound_plug.value = 'NewValue'
    assert in_compound_plug.is_dirty
示例#6
0
def test_plug_gets_dirty_only_on_change(clear_default_graph):
    """Test that plugs only change dirtyness if a real change happens."""
    in_test, out_test = "foo", "bar"
    n1 = NodeForTesting(name="n1")
    n2 = NodeForTesting(name="n2")
    out_plug = OutputPlug("out", n1)
    in_plug = InputPlug("in", n2)

    out_plug >> in_plug

    in_plug.value = in_test
    out_plug.value = out_test
    assert in_plug.is_dirty
    assert out_plug.is_dirty

    in_plug.is_dirty = False
    out_plug.is_dirty = False
    assert not in_plug.is_dirty
    assert not out_plug.is_dirty

    same_val = in_plug.value
    in_plug.value = same_val
    assert not in_plug.is_dirty
    assert not out_plug.is_dirty

    out_plug.value = out_test
    assert not in_plug.is_dirty
    assert not out_plug.is_dirty

    out_plug.value = "baz"
    assert in_plug.is_dirty
    assert out_plug.is_dirty
示例#7
0
def test_change_connections_sets_plug_dirty(clear_default_graph):
    """Connecting and disconnecting sets the plug dirty."""
    n1 = NodeForTesting(name="n1")
    n2 = NodeForTesting(name="n2")
    out_plug = OutputPlug("out", n1)
    in_plug = InputPlug("in", n2)
    out_compound_plug = OutputPlug("out_compound", n1)
    in_compound_plug = InputPlug("in_compound", n2)

    in_plug.is_dirty = False
    out_plug >> in_plug
    assert in_plug.is_dirty

    in_plug.is_dirty = False
    out_plug << in_plug
    assert in_plug.is_dirty

    in_compound_plug["0"].is_dirty = False
    out_compound_plug["0"] >> in_compound_plug["0"]
    assert in_compound_plug["0"].is_dirty

    in_compound_plug["0"].is_dirty = False
    out_compound_plug["0"] << in_compound_plug["0"]
    assert in_compound_plug["0"].is_dirty
示例#8
0
def test_change_connections_sets_plug_dirty(clear_default_graph):
    """Connecting and disconnecting sets the plug dirty."""
    n1 = NodeForTesting(name='n1')
    n2 = NodeForTesting(name='n2')
    out_plug = OutputPlug('out', n1)
    in_plug = InputPlug('in', n2)
    out_compound_plug = OutputPlug('out_compound', n1)
    in_compound_plug = InputPlug('in_compound', n2)

    in_plug.is_dirty = False
    out_plug >> in_plug
    assert in_plug.is_dirty

    in_plug.is_dirty = False
    out_plug << in_plug
    assert in_plug.is_dirty

    in_compound_plug['0'].is_dirty = False
    out_compound_plug['0'] >> in_compound_plug['0']
    assert in_compound_plug['0'].is_dirty

    in_compound_plug['0'].is_dirty = False
    out_compound_plug['0'] << in_compound_plug['0']
    assert in_compound_plug['0'].is_dirty