コード例 #1
0
 def test_declare_task(self):
     app = WorkerApplication()
     app.declare_taskgroup('testgroup', 'testexchange', 'testroutingkey')
     app.tasks = MagicMock()
     app.declare_task('testgroup', 'taskname')
     app.tasks._declare.assert_called_with('taskname',
                                           exchange='testexchange',
                                           routing_key='testroutingkey')
コード例 #2
0
 def test_register_module(self):
     app = WorkerApplication()
     app.declare_task = MagicMock()
     app.register_task = MagicMock()
     mod = MagicMock()
     mod.__all__ = ['func1', 'func2']
     mod.__declare_tasks__ = [('testgroup', 'testtask')]
     mod.func1 = MagicMock(__name__='func1')
     mod.func2 = MagicMock(__name__='func2')
     app.register_module(mod, 't_')
     app.register_task.assert_any_call(mod.func1, 't_func1', None)
     app.register_task.assert_any_call(mod.func2, 't_func2', None)
     app.declare_task.assert_called_with('testgroup', 'testtask')