def test_model_observe_child_adding_removing(task):
    """Test that adding removing a child does trigger the expected behavior.

    """
    model = ExecutionEditorModel(root=task)
    assert model.pools == ['test']

    c = ComplexTask(name='comp2',
                    parallel={
                        'activated': True,
                        'pool': 'test2'
                    })
    task.add_child_task(2, c)
    assert 'test2' in model.pools

    c.add_child_task(
        0,
        SimpleTask(name='simp3', parallel={
            'activated': True,
            'pool': 'test3'
        }))
    assert 'test3' in model.pools

    task.move_child_task(2, 0)
    assert sorted(model.pools) == ['test', 'test2', 'test3']

    task.remove_child_task(0)
    assert model.pools == ['test']

    model.root = None
    task.children[0].parallel = {'activated': True, 'pool': 'test2'}
    assert 'test2' not in model.pools

    # For coverage
    model._children_observer(ContainerChange(collapsed=[ContainerChange()]))
예제 #2
0
def test_model_observe_child_adding_removing(task):
    """Test that adding removing a child does trigger the expected behavior.

    """
    model = ExecutionEditorModel(root=task)
    assert model.pools == ["test"]

    c = ComplexTask(name="comp2", parallel={"activated": True, "pool": "test2"})
    task.add_child_task(2, c)
    assert "test2" in model.pools

    c.add_child_task(0, SimpleTask(name="simp3", parallel={"activated": True, "pool": "test3"}))
    assert "test3" in model.pools

    task.move_child_task(2, 0)
    assert sorted(model.pools) == ["test", "test2", "test3"]

    task.remove_child_task(0)
    assert model.pools == ["test"]

    model.root = None
    task.children[0].parallel = {"activated": True, "pool": "test2"}
    assert "test2" not in model.pools

    # For coverage
    model._children_observer(ContainerChange(collapsed=[ContainerChange()]))
def test_model_observe_wait(task):
    """Test that the model is properly updated when the wait setting of a task
    change.

    """
    model = ExecutionEditorModel(root=task)
    assert model.pools == ['test']

    child = task.children[1].children[0]

    child.wait = {'activated': True, 'wait': ['test2']}
    assert 'test2' in model.pools

    child.wait = {'activated': False, 'wait': ['test2']}
    assert 'test2' not in model.pools

    child.wait = {'activated': True, 'no_wait': ['test2']}
    assert 'test2' in model.pools

    child = task.children[1]

    child.wait = {'activated': True, 'wait': ['test3']}
    assert 'test3' in model.pools

    child.wait = {'activated': False, 'wait': ['test3']}
    assert 'test3' not in model.pools
예제 #4
0
def test_model_observe_child_member(task):
    """Test that replacing a child does trigger the expected behavior.

    """
    model = ExecutionEditorModel(root=task)
    assert model.pools == ['test']

    c = LoopTask(name='comp2', parallel={'activated': True, 'pool': 'test2'})
    task.add_child_task(2, c)
    assert 'test2' in model.pools

    c.children = [
        SimpleTask(name='simp3', parallel={
            'activated': True,
            'pool': 'test3'
        })
    ]
    assert 'test3' in model.pools

    c.children = []
    assert sorted(model.pools) == sorted(['test', 'test2'])

    c.task = SimpleTask(name='simp3',
                        parallel={
                            'activated': True,
                            'pool': 'test4'
                        })
    assert 'test4' in model.pools

    c.task = None
    assert sorted(model.pools) == sorted(['test', 'test2'])
def test_model_observe_parallel(task):
    """Test that the model is properly updated when the parallel setting of a
    task changes.

    """
    model = ExecutionEditorModel(root=task)
    assert model.pools == ['test']

    task.children[0].parallel = {'activated': True, 'pool': 'test2'}
    assert 'test2' in model.pools

    task.children[0].parallel = {'activated': False, 'pool': 'test2'}
    assert 'test2' not in model.pools

    model.unbind_observers()
    task.children[0].parallel = {'activated': True, 'pool': 'test2'}
    assert 'test2' not in model.pools
예제 #6
0
def test_model_observe_parallel(task):
    """Test that the model is properly updated when the parallel setting of a
    task changes.

    """
    model = ExecutionEditorModel(root=task)
    assert model.pools == ["test"]

    task.children[0].parallel = {"activated": True, "pool": "test2"}
    assert "test2" in model.pools

    task.children[0].parallel = {"activated": False, "pool": "test2"}
    assert "test2" not in model.pools

    model.unbind_observers()
    task.children[0].parallel = {"activated": True, "pool": "test2"}
    assert "test2" not in model.pools