def test_to_task_has_correct_arguments(self, memcache, time, task, task_retry): """Ensure that if no name is passed into the MessageProcessor that it creates a default unique name when creating the task. """ from furious. async import MAX_RESTARTS from furious.batcher import MessageProcessor memcache.get.return_value = 'current-batch' time.time.return_value = 100 task_retry_object = Mock() task_retry.return_value = task_retry_object processor = MessageProcessor('something', queue='test_queue', id='someid', parent_id='parentid', context_id="contextid") processor.to_task() task_args = { 'name': 'processor-processor-current-batch-3', 'url': '/_ah/queue/async/something', 'countdown': 30, 'headers': {}, 'retry_options': task_retry_object, 'payload': json.dumps(processor.to_dict()) } task.assert_called_once_with(**task_args) task_retry.assert_called_once_with(task_retry_limit=MAX_RESTARTS)
def test_to_task_has_correct_arguments(self, memcache, time, task, task_retry): """Ensure that if no name is passed into the MessageProcessor that it creates a default unique name when creating the task. """ from furious.async import MAX_RESTARTS from furious.batcher import MessageProcessor memcache.get.return_value = 'current-batch' time.time.return_value = 100 task_retry_object = Mock() task_retry.return_value = task_retry_object processor = MessageProcessor('something', queue='test_queue', id='someid', parent_id='parentid', context_id="contextid") processor.to_task() task_args = { 'name': 'processor-processor-current-batch-3', 'url': '/_ah/queue/async/something', 'countdown': 30, 'headers': {}, 'retry_options': task_retry_object, 'payload': json.dumps(processor.to_dict()) } task.assert_called_once_with(**task_args) task_retry.assert_called_once_with(task_retry_limit=MAX_RESTARTS)
def test_has_type(self): """Ensure that if _type is not furious.async.Async that the correct subclass is instantiated. """ from furious.async import async_from_options from furious.batcher import MessageProcessor async_job = MessageProcessor(dir) options = async_job.to_dict() result = async_from_options(options) self.assertIsInstance(result, MessageProcessor)
def test_has_type(self): """Ensure that if _type is not furious.async.Async that the correct subclass is instantiated. """ from furious. async import async_from_options from furious.batcher import MessageProcessor async_job = MessageProcessor(dir) options = async_job.to_dict() result = async_from_options(options) self.assertIsInstance(result, MessageProcessor)