コード例 #1
0
ファイル: test_base.py プロジェクト: m4ddav3/celery
 def test_chord_error_from_stack_raises(self):
     b = BaseBackend(app=self.app)
     exc = KeyError()
     callback = Mock(name="callback")
     callback.options = {"link_error": []}
     task = self.app.tasks[callback.task] = Mock()
     b.fail_from_current_stack = Mock()
     group = self.patch("celery.group")
     group.side_effect = exc
     b.chord_error_from_stack(callback, exc=ValueError())
     task.backend.fail_from_current_stack.assert_called_with(callback.id, exc=exc)
コード例 #2
0
 def test_chord_error_from_stack_raises(self):
     b = BaseBackend(app=self.app)
     exc = KeyError()
     callback = Mock(name='callback')
     callback.options = {'link_error': []}
     task = self.app.tasks[callback.task] = Mock()
     b.fail_from_current_stack = Mock()
     group = self.patching('celery.group')
     group.side_effect = exc
     b.chord_error_from_stack(callback, exc=ValueError())
     task.backend.fail_from_current_stack.assert_called_with(
         callback.id, exc=exc)
コード例 #3
0
    def test_chord_error_from_stack_raises(self):
        class ExpectedException(Exception):
            pass

        b = BaseBackend(app=self.app)
        callback = MagicMock(name='callback')
        callback.options = {'link_error': []}
        callback.keys.return_value = []
        task = self.app.tasks[callback.task] = Mock()
        b.fail_from_current_stack = Mock()
        self.patching('celery.group')
        with patch.object(
            b, "_call_task_errbacks", side_effect=ExpectedException()
        ) as mock_call_errbacks:
            b.chord_error_from_stack(callback, exc=ValueError())
        task.backend.fail_from_current_stack.assert_called_with(
            callback.id, exc=mock_call_errbacks.side_effect,
        )