Beispiel #1
0
 def test_process_task_raise_regular(self):
     worker = self.worker
     worker.pool = Mock()
     worker.pool.apply_async.side_effect = KeyError("some exception")
     backend = Mock()
     m = create_message(backend, task=foo_task.name, args=[4, 8, 10], kwargs={})
     task = Request.from_message(m, m.decode())
     worker.process_task(task)
     worker.pool.stop()
Beispiel #2
0
 def test_process_task(self):
     worker = self.worker
     worker.pool = Mock()
     backend = Mock()
     m = create_message(backend, task=foo_task.name, args=[4, 8, 10], kwargs={})
     task = Request.from_message(m, m.decode())
     worker.process_task(task)
     self.assertEqual(worker.pool.apply_async.call_count, 1)
     worker.pool.stop()
Beispiel #3
0
 def test_process_task_raise_regular(self):
     worker = self.worker
     worker.pool = Mock()
     worker.pool.apply_async.side_effect = KeyError('some exception')
     backend = Mock()
     m = create_message(backend, task=foo_task.name, args=[4, 8, 10],
                        kwargs={})
     task = Request.from_message(m, m.decode())
     worker.process_task(task)
     worker.pool.stop()
Beispiel #4
0
 def test_process_task(self):
     worker = self.worker
     worker.pool = Mock()
     backend = Mock()
     m = create_message(backend, task=foo_task.name, args=[4, 8, 10],
                        kwargs={})
     task = Request.from_message(m, m.decode())
     worker.process_task(task)
     self.assertEqual(worker.pool.apply_async.call_count, 1)
     worker.pool.stop()
Beispiel #5
0
 def test_process_task_raise_SystemTerminate(self):
     worker = self.worker
     worker.pool = Mock()
     worker.pool.apply_async.side_effect = SystemTerminate()
     backend = Mock()
     m = create_message(backend, task=foo_task.name, args=[4, 8, 10], kwargs={})
     task = Request.from_message(m, m.decode())
     worker.components = []
     worker._state = worker.RUN
     with self.assertRaises(SystemExit):
         worker.process_task(task)
     self.assertEqual(worker._state, worker.TERMINATE)
Beispiel #6
0
 def test_process_task_raise_base(self):
     worker = self.worker
     worker.pool = Mock()
     worker.pool.apply_async.side_effect = KeyboardInterrupt("Ctrl+C")
     backend = Mock()
     m = create_message(backend, task=foo_task.name, args=[4, 8, 10], kwargs={})
     task = Request.from_message(m, m.decode())
     worker.components = []
     worker.namespace.state = RUN
     with self.assertRaises(KeyboardInterrupt):
         worker.process_task(task)
     self.assertEqual(worker.namespace.state, TERMINATE)
Beispiel #7
0
 def test_process_task_raise_SystemTerminate(self):
     worker = self.worker
     worker.pool = Mock()
     worker.pool.apply_async.side_effect = SystemTerminate()
     backend = Mock()
     m = create_message(backend, task=foo_task.name, args=[4, 8, 10],
                        kwargs={})
     task = Request.from_message(m, m.decode())
     worker.steps = []
     worker.namespace.state = RUN
     with self.assertRaises(SystemExit):
         worker.process_task(task)
     self.assertEqual(worker.namespace.state, TERMINATE)
Beispiel #8
0
 def test_process_task_raise_base(self):
     worker = self.worker
     worker.pool = Mock()
     worker.pool.apply_async.side_effect = KeyboardInterrupt('Ctrl+C')
     backend = Mock()
     m = create_message(backend, task=foo_task.name, args=[4, 8, 10],
                        kwargs={})
     task = Request.from_message(m, m.decode())
     worker.components = []
     worker._state = worker.RUN
     with self.assertRaises(KeyboardInterrupt):
         worker.process_task(task)
     self.assertEqual(worker._state, worker.TERMINATE)