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
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')