コード例 #1
0
 def setUp(self):
     app = mock.Mock(**{
         'conf.result_serializer': 'json',
         'conf.accept_content': None
     })
     self.backend = Backend(app)
     errback = {
         "chord_size": None,
         "task": "waldur_core.core.tasks.ErrorStateTransitionTask",
         "args": ["waldur.obj:1"],
         "immutable": False,
         "subtask_type": None,
         "kwargs": {},
         "options": {}
     }
     self.request = Context(errbacks=[errback],
                            id='task_id',
                            root_id='root_id')
コード例 #2
0
 def get_drainer(self, environment):
     with patch('celery.backends.asynchronous.detect_environment') as d:
         d.return_value = environment
         backend = Backend(self.app)
         consumer = BaseResultConsumer(backend, self.app, backend.accept,
                                       pending_results={},
                                       pending_messages={})
         consumer.drain_events = Mock(side_effect=self.result_consumer_drain_events)
         return consumer.drainer
コード例 #3
0
class ExecutorTest(testcases.TestCase):
    def setUp(self):
        app = mock.Mock(**{
            'conf.result_serializer': 'json',
            'conf.accept_content': None
        })
        self.backend = Backend(app)
        errback = {
            "chord_size": None,
            "task": "waldur_core.core.tasks.ErrorStateTransitionTask",
            "args": ["waldur.obj:1"],
            "immutable": False,
            "subtask_type": None,
            "kwargs": {},
            "options": {}
        }
        self.request = Context(errbacks=[errback],
                               id='task_id',
                               root_id='root_id')

    @mock.patch('waldur_core.core.tasks.group')
    def test_use_old_signature_in_task_error(self, mock_group):
        self.backend._call_task_errbacks(self.request, Exception('test'), '')
        self.assertEqual(mock_group.call_count, 1)