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_analysing_task_dependencies(monkeypatch, task_workbench, task_dep_collector): """Test analysing the dependencies of a task. """ runtime = ['test'] plugin = task_workbench.get_plugin('ecpy.tasks') monkeypatch.setattr(plugin.get_task_infos('ecpy.ComplexTask'), 'dependencies', runtime) dep = set() errors = dict() run = task_dep_collector.analyse(task_workbench, ComplexTask(), getattr, dep, errors) assert run == runtime assert 'ecpy.ComplexTask' in dep assert not errors dep = set() run = task_dep_collector.analyse(task_workbench, {'task_id': '__dummy__'}, getitem, dep, errors) assert not run assert not dep assert '__dummy__' in errors
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_node_sorting(task): """Test that a node model correctly order its children and react to task re-ordering. """ ed = EditorModel(root=task) nmodel = ed.nodes['root'] task.add_child_task(0, ComplexTask(name='cc')) nmodel.sort_nodes() assert [c.task.name for c in nmodel.children] == ['cc', 'comp1'] assert sorted(nmodel.entries) == sorted( ['default_path', 'simp1_t', 'comp1_t1', 'comp1_t2']) task.move_child_task(0, 2) assert [c.task.name for c in nmodel.children] == ['comp1', 'cc'] assert (sorted(nmodel.children[0].entries) == sorted( ['simp2_t', 'comp2_t1', 'comp2_t2'])) change = ContainerChange(collapsed=[ContainerChange()]) nmodel._react_to_task_children_event(change) # For coverage
def test_handling_node_manipulation(task): """Test handling manipulation occuring on a node. """ ed = EditorModel(root=task) cc = ComplexTask(name='cc') task.add_child_task(0, cc) assert 'root/cc' in ed.nodes assert cc is ed.nodes['root'].children[0].task task.remove_child_task(0) assert 'root/cc' not in ed.nodes # For coverage check that we could handle a list of changes ed._react_to_nodes([('', '', '')]) # Test failing to find a task by path with pytest.raises(ValueError): ed._get_task('root/unknown')
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(): root = RootTask() root.add_child_task(0, ComplexTask(name='Dummy')) return root