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()]))
Ejemplo n.º 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()]))
Ejemplo n.º 3
0
def task():
    """Create a basic task hierarchy for testing.

    """
    root = RootTask()
    root.add_child_task(0, SimpleTask(name="simp1"))

    comp = ComplexTask(name="comp1", wait={"activated": True, "no_wait": ["test"]})
    comp.add_child_task(0, SimpleTask(name="simp2", parallel={"activated": True, "pool": "test"}))

    root.add_child_task(1, comp)
    return root
def task():
    """Create a basic task hierarchy for testing.

    """
    root = RootTask()
    root.add_child_task(0, SimpleTask(name='simp1'))

    comp = ComplexTask(name='comp1',
                       wait={
                           'activated': True,
                           'no_wait': ['test']
                       })
    comp.add_child_task(
        0,
        SimpleTask(name='simp2', parallel={
            'activated': True,
            'pool': 'test'
        }))

    root.add_child_task(1, comp)
    return root
Ejemplo n.º 5
0
def task():
    r = RootTask()
    r.add_child_task(0, SimpleTask(name='simp1', database_entries={'t': 1}))
    c = ComplexTask(name='comp1', database_entries={'t1': 2, 't2': 'r'})
    c.add_child_task(0, SimpleTask(name='simp2', database_entries={'t': 1}))
    c2 = ComplexTask(name='comp2', database_entries={'t1': 2, 't2': 'r'})
    c2.add_child_task(0, SimpleTask(name='simp3', database_entries={'t': 1}))
    c.add_child_task(1, c2)
    r.add_child_task(1, c)
    return r
Ejemplo n.º 6
0
def task():
    r = RootTask()
    r.add_child_task(0, SimpleTask(name='simp1', database_entries={'t': 1}))
    c = ComplexTask(name='comp1', database_entries={'t1': 2, 't2': 'r'})
    c.add_child_task(0,
                     SimpleTask(name='simp2', database_entries={'t': 1}))
    c2 = ComplexTask(name='comp2', database_entries={'t1': 2, 't2': 'r'})
    c2.add_child_task(0,
                      SimpleTask(name='simp3', database_entries={'t': 1}))
    c.add_child_task(1, c2)
    r.add_child_task(1, c)
    return r