Remove the sleep() in tick() that causes a minimum execution time of 2*PERIOD, more explicit status display and a small test case for console plugin.
This commit is contained in:
36
tests/plugins/test_console.py
Normal file
36
tests/plugins/test_console.py
Normal file
@ -0,0 +1,36 @@
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
import bonobo
|
||||
from bonobo.execution import events
|
||||
from bonobo.execution.graph import GraphExecutionContext
|
||||
from bonobo.plugins.console import ConsoleOutputPlugin
|
||||
from whistle import EventDispatcher
|
||||
|
||||
|
||||
def test_register_unregister():
|
||||
plugin = ConsoleOutputPlugin()
|
||||
dispatcher = EventDispatcher()
|
||||
|
||||
plugin.register(dispatcher)
|
||||
assert plugin.setup in dispatcher.get_listeners(events.START)
|
||||
assert plugin.tick in dispatcher.get_listeners(events.TICK)
|
||||
assert plugin.teardown in dispatcher.get_listeners(events.STOPPED)
|
||||
plugin.unregister(dispatcher)
|
||||
assert plugin.setup not in dispatcher.get_listeners(events.START)
|
||||
assert plugin.tick not in dispatcher.get_listeners(events.TICK)
|
||||
assert plugin.teardown not in dispatcher.get_listeners(events.STOPPED)
|
||||
|
||||
|
||||
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)
|
||||
Reference in New Issue
Block a user