def test_to_task_has_correct_arguments(self, memcache, time, task): """Ensure that if no name is passed into the MessageProcessor that it creates a default unique name when creating the task. """ from furious.batcher import MessageProcessor memcache.get.return_value = 'current-batch' time.time.return_value = 100 processor = MessageProcessor('something', queue='test_queue') processor.to_task() task_args = { 'url': '/_ah/queue/async/something', 'headers': {}, 'payload': json.dumps({ 'queue': 'test_queue', 'job': ["something", None, None], 'task_args': { 'countdown': 30, 'name': 'processor-processor-current-batch-3' }, }), 'countdown': 30, 'name': 'processor-processor-current-batch-3' } task.assert_called_once_with(**task_args)
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_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') processor.to_task() task_args = { 'url': '/_ah/queue/async/something', 'headers': {}, 'payload': json.dumps({ 'queue': 'test_queue', 'job': ("something", None, None), 'id': 'someid', 'task_args': { 'countdown': 30, 'name': 'processor-processor-current-batch-3' }, '_recursion': { 'current': 1, 'max': 100 }, '_type': 'furious.batcher.MessageProcessor', }), 'countdown': 30, 'name': 'processor-processor-current-batch-3', 'retry_options': task_retry_object } 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') processor.to_task() task_args = { 'url': '/_ah/queue/async/something', 'headers': {}, 'payload': json.dumps({ 'queue': 'test_queue', 'job': ("something", None, None), 'id': 'someid', 'task_args': { 'countdown': 30, 'name': 'processor-processor-current-batch-3' }, '_recursion': { 'current': 1, 'max': 100 }, '_type': 'furious.batcher.MessageProcessor', }), 'countdown': 30, 'name': 'processor-processor-current-batch-3', 'retry_options': task_retry_object } task.assert_called_once_with(**task_args) task_retry.assert_called_once_with(task_retry_limit=MAX_RESTARTS)
def test_to_task_with_frequency_passed_in(self, memcache, time): """Ensure that if a frequency is passed into the MessageProcessor that it uses that frequency when creating the task. """ from furious.batcher import MessageProcessor memcache.get.return_value = 'current-batch' time.time.return_value = 100 processor = MessageProcessor('something', queue='test_queue', freq=100) task = processor.to_task() self.assertEqual(task.name, 'processor-processor-current-batch-1')
def test_to_task_with_no_name_passed_in(self, memcache, time): """Ensure that if no name is passed into the MessageProcessor that it creates a default unique name when creating the task. """ from furious.batcher import MessageProcessor memcache.get.return_value = 'current-batch' time.time.return_value = 100 processor = MessageProcessor('something', queue='test_queue') task = processor.to_task() self.assertEqual(task.name, 'processor-processor-current-batch-3')
def test_to_task_with_frequency_passed_in(self, memcache, time): """Ensure that if a frequency is passed into the MessageProcessor that it uses that frequency when creating the task. """ from furious.batcher import MessageProcessor memcache.get.return_value = 'current-batch' time.time.return_value = 100 processor = MessageProcessor('something', queue='test_queue', freq=100) task = processor.to_task() self.assertEqual(task.name, 'processor-processor-current-batch-1')
def test_to_task_with_no_name_passed_in(self, memcache, time): """Ensure that if no name is passed into the MessageProcessor that it creates a default unique name when creating the task. """ from furious.batcher import MessageProcessor memcache.get.return_value = 'current-batch' time.time.return_value = 100 processor = MessageProcessor('something', queue='test_queue') task = processor.to_task() self.assertEqual(task.name, 'processor-processor-current-batch-3')
def test_to_task_with_name_passed_in(self, memcache, time): """Ensure that if a name is passed into the MessageProcessor that it uses that name when creating the task. """ from furious.batcher import MessageProcessor memcache.get.return_value = 'current-batch' time.time.return_value = 100 processor = MessageProcessor('something', queue='test_queue', task_args={'name': 'test-name'}) task = processor.to_task() self.assertEqual(task.name, 'test-name-processor-current-batch-3')
def test_to_task_with_tag_not_passed_in(self, memcache, time): """Ensure that if a tag is not passed into the MessageProcessor that it uses a default value when creating the task. """ from furious.batcher import MessageProcessor memcache.get.return_value = 'current-batch' time.time.return_value = 100 processor = MessageProcessor('something', queue='test_queue') task = processor.to_task() self.assertEqual(task.name, 'processor-processor-current-batch-3') memcache.get.assert_called_once_with('agg-batch-processor')
def test_to_task_with_name_passed_in(self, memcache, time): """Ensure that if a name is passed into the MessageProcessor that it uses that name when creating the task. """ from furious.batcher import MessageProcessor memcache.get.return_value = 'current-batch' time.time.return_value = 100 processor = MessageProcessor('something', queue='test_queue', task_args={'name': 'test-name'}) task = processor.to_task() self.assertEqual(task.name, 'test-name-processor-current-batch-3')
def test_to_task_with_tag_not_passed_in(self, memcache, time): """Ensure that if a tag is not passed into the MessageProcessor that it uses a default value when creating the task. """ from furious.batcher import MessageProcessor memcache.get.return_value = 'current-batch' time.time.return_value = 100 processor = MessageProcessor('something', queue='test_queue') task = processor.to_task() self.assertEqual(task.name, 'processor-processor-current-batch-3') memcache.get.assert_called_once_with('agg-batch-processor')