Esempio n. 1
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')
Esempio n. 2
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')
Esempio n. 3
0
 def test_register_task(self):
     @taskgroup('testgroup')
     def func1():
         pass
     def func2():
         pass
     app = WorkerApplication()
     app.declare_taskgroup('testgroup', 'testexchange', 'testroutingkey')
     app.tasks = MagicMock()
     app.register_task(func1, 'funcone')
     app.tasks._set.assert_called_with(func1, 'funcone',
                                       exchange='testexchange',
                                       routing_key='testroutingkey')
     app.register_task(func2, taskgroup='testgroup')
     app.tasks._set.assert_called_with(func2, 'func2',
                                       exchange='testexchange',
                                       routing_key='testroutingkey')