def test_simple_execution_context(): graph = Graph() graph.add_chain(*chain) context = GraphExecutionContext(graph) assert len(context.nodes) == len(chain) assert not len(context.plugins) for i, node in enumerate(chain): assert context[i].wrapped is node assert not context.alive assert not context.started assert not context.stopped context.write(BEGIN, (), END) assert not context.alive assert not context.started assert not context.stopped context.start() assert context.alive assert context.started assert not context.stopped context.stop() assert not context.alive assert context.started assert context.stopped
def test_empty_execution_context(): graph = Graph() ctx = GraphExecutionContext(graph) assert not len(ctx.nodes) assert not len(ctx.plugins) assert not ctx.alive
def test_one_pass(): plugin = ConsoleOutputPlugin() dispatcher = EventDispatcher() plugin.register(dispatcher) graph = bonobo.Graph() context = MagicMock(spec=GraphExecutionContext(graph)) dispatcher.dispatch(events.START, events.ExecutionEvent(context)) dispatcher.dispatch(events.TICK, events.ExecutionEvent(context)) dispatcher.dispatch(events.STOPPED, events.ExecutionEvent(context)) plugin.unregister(dispatcher)
def __init__(self, *args, buffer=None, **kwargs): BufferingContext.__init__(self, buffer) GraphExecutionContext.__init__(self, *args, **kwargs)