예제 #1
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'])
예제 #2
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
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()]))
예제 #4
0
def test_editor_modifying_exception_level(task):
    """Test modifying the level of an access exception.

    """
    ed = EditorModel(root=task)
    rnode = ed.nodes['root']

    node = rnode.children[0].children[0]
    # Check that we can desambiguate between task with same prefix
    node.task.add_child_task(
        0, SimpleTask(name='simp3_t', database_entries={'t': 1}))
    node.add_exception('simp3_t')
    assert 'simp3_t' in node.parent.exceptions
    assert 't' in node.task.children[1].access_exs

    ed.increase_exc_level('root/comp1', 'simp3_t')
    assert 'simp3_t' not in node.parent.exceptions
    assert 'simp3_t' in node.parent.parent.exceptions

    ed.decrease_exc_level('root', 'simp3_t')
    assert 'simp3_t' in node.parent.exceptions
    assert 'simp3_t' not in node.parent.parent.exceptions

    ed.decrease_exc_level('root/comp1', 'simp3_t')
    assert 'simp3_t' not in node.parent.exceptions
    assert 't' not in node.task.children[1].access_exs

    node.parent.add_exception('simp2_t')
    assert 'simp2_t' in node.parent.parent.exceptions
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