def tasks(): return { 'SimpleTask': TaskInfos(cls=SimpleTask, metadata={'meta': True}), 'ComplexTask': TaskInfos(cls=ComplexTask, metadata={ 'group': 'Complex', 'meta': False }) }
def exec_infos(measure_workbench, measure, tmpdir, process_engine, sync_server): tp = measure_workbench.get_plugin('ecpy.tasks') tp._tasks.contributions['tests.WaitingTask'] = TaskInfos(cls=WaitingTask) r = RootTask(default_path=text(tmpdir)) r.add_child_task( 0, WaitingTask(name='test1', sock_id='test1', sync_port=sync_server.port)) r.add_child_task( 1, WaitingTask(name='test2', sock_id='test2', sync_port=sync_server.port)) measure.root_task = r deps = measure.dependencies res, msg, errors = deps.collect_runtimes() assert res return ExecutionInfos( id='test', task=r, build_deps=deps.get_build_dependencies().dependencies, runtime_deps=deps.get_runtime_dependencies('main'), observed_entries=['test'], checks=not measure.forced_enqueued, )
def test_register_task_decl_extend1(collector, task_decl): """Test extending a task. """ collector.contributions['ecpy.Task'] = TaskInfos() task_decl.task = 'ecpy.Task' task_decl.instruments = ['test'] task_decl.register(collector, {}) assert collector.contributions['ecpy.Task'].instruments == set(['test'])
def test_register_interface_extend_task(collector, int_decl): """Test extending a task by adding interfaces. """ collector.contributions['ecpy.Task'] = TaskInfos() task, _ = int_decl task.task = 'ecpy.Task' task.register(collector, {}) assert collector.contributions['ecpy.Task'].interfaces
def test_register_task_decl_extend3(collector, task_decl): """Test extending a task using wrong children. """ tb = {} collector.contributions['ecpy.Task'] = TaskInfos() task_decl.task = 'ecpy.Task' task_decl.insert_children(None, [Task()]) task_decl.register(collector, tb) assert 'ecpy.Task' in tb
def test_register_interface_decl_duplicate1(int_decl, collector): """Test handling duplicate : in collector. """ tb = {} task, i = int_decl infos = TaskInfos(interfaces={i.interface.rsplit(':', 1)[1]: None}) collector.contributions[task.id] = infos i.register(collector, tb) assert 'ecpy.LoopTask.IterableLoopInterface_duplicate1' in tb
def test_unregister_task_decl3(collector, task_decl): """Test unregistering a task simply contributing instruments. """ collector.contributions['ecpy.Task'] = TaskInfos() task_decl.task = 'Task' task_decl.instruments = ['test'] task_decl.register(collector, {}) task_decl.unregister(collector) assert not collector.contributions['ecpy.Task'].instruments
def test_register_interface_extend_interface2(collector, int_decl): """Test extending an interface not yet declared. """ collector.contributions['ecpy.Task'] = TaskInfos() task, interface = int_decl task.task = 'ecpy.Task' interface.interface = 'Test' interface.instruments = ['test'] task.register(collector, {}) assert collector._delayed == [interface]
def test_register_interface_decl_children2(int_decl, collector): """Test handling child type issue when extending. """ infos = TaskInfos() infos.interfaces['Test'] = InterfaceInfos() collector.contributions['ecpy.Task'] = infos task, interface = int_decl task.task = 'ecpy.Task' interface.interface = 'Test' interface.insert_children(None, [Task()]) tb = {} task.register(collector, tb) assert 'ecpy.Task.Test' in tb and 'Interface' in tb['ecpy.Task.Test']
def test_register_interface_extend_interface1(collector, int_decl): """Test extending an interface. """ infos = TaskInfos() infos.interfaces['Test'] = InterfaceInfos() collector.contributions['ecpy.Task'] = infos task, interface = int_decl task.task = 'ecpy.Task' interface.interface = 'Test' interface.instruments = ['test'] task.register(collector, {}) interface = collector.contributions['ecpy.Task'].interfaces['Test'] assert interface.instruments == {'test'}
def test_unregister_interface_decl4(collector, int_decl): """Test unregistering an interface simply contributing instruments. """ infos = TaskInfos() infos.interfaces['Test'] = InterfaceInfos() collector.contributions['ecpy.Task'] = infos task, interface = int_decl task.task = 'ecpy.Task' interface.interface = 'Test' interface.instruments = ['test'] task.register(collector, {}) interface = collector.contributions['ecpy.Task'].interfaces['Test'] assert interface.instruments == {'test'} task.unregister(collector) assert not interface.instruments
def test_nested_interfaces_extend1(nested_int_decl, collector): """Test registering, unregistering an interface extending an interface to an interface. """ infos = TaskInfos() infos.interfaces['Test'] = InterfaceInfos( interfaces={'Nested': InterfaceInfos()}) collector.contributions['ecpy.Task'] = infos task, interface = nested_int_decl task.task = 'ecpy.Task' interface.parent.interface = 'Test' interface.interface = 'Nested' interface.instruments = ['test'] task.register(collector, {}) i = collector.contributions['ecpy.Task'].interfaces['Test'] assert i.interfaces['Nested'].instruments == {'test'} interface.parent.unregister(collector)