예제 #1
0
 def test_reject_delay(self):
     """Rejected task is requeued after delay"""
     tasks.rejecting_task_with_delay()
     with run_worker() as worker:
         worker.expect('Task is rejected')
         assert len_queue("kuyruk") == 0
         worker.expect('Task is rejected')
     assert len_queue("kuyruk") == 1
예제 #2
0
 def test_reject(self):
     """Rejected task is requeued"""
     tasks.rejecting_task()
     with run_kuyruk() as worker:
         worker.expect('Task is rejected')
         worker.expect('Task is rejected')
     assert len_queue("kuyruk") == 1
예제 #3
0
 def test_reject(self):
     """Rejected task is requeued"""
     tasks.rejecting_task()
     with run_worker() as worker:
         worker.expect('Task is rejected')
         worker.expect('Task is rejected')
     assert len_queue("kuyruk") == 1
예제 #4
0
 def test_retry(self):
     """Errored task is retried"""
     tasks.retry_task()
     with run_kuyruk() as worker:
         worker.expect('ZeroDivisionError')
         worker.expect('ZeroDivisionError')
     assert len_queue("kuyruk") == 0
예제 #5
0
 def test_retry(self):
     """Errored task is retried"""
     tasks.retry_task()
     with run_kuyruk() as worker:
         worker.expect('ZeroDivisionError')
         worker.expect('ZeroDivisionError')
     assert len_queue("kuyruk") == 0
예제 #6
0
파일: test_worker.py 프로젝트: cenk/kuyruk
 def test_worker_sigquit(self):
     """Worker drops the task on SIGQUIT"""
     tasks.loop_forever()
     with run_worker() as worker:
         worker.expect('looping forever')
         worker.send_signal(signal.SIGUSR2)
         worker.expect('Dropping current task')
     assert len_queue("kuyruk") == 0, worker.get_output()
예제 #7
0
 def test_worker_sigquit(self):
     """Worker drops the task on SIGQUIT"""
     tasks.loop_forever()
     with run_worker() as worker:
         worker.expect('looping forever')
         worker.send_signal(signal.SIGUSR2)
         worker.expect('Dropping current task')
     assert len_queue("kuyruk") == 0, worker.get_output()
예제 #8
0
 def test_another_queue(self):
     """Task is run on another queue"""
     delete_queue('another_queue')
     tasks.echo_another('hello another')
     assert len_queue('another_queue') == 1
     with run_worker(queue='another_queue') as worker:
         worker.expect('Consumer started')
         worker.expect('hello another')
         worker.expect('Task is processed')
예제 #9
0
 def test_invalid_json(self):
     """Message is dropped when JSON is not valid"""
     with run_worker() as worker:
         worker.expect('Consumer started')
         with new_instance().channel() as ch:
             msg = amqp.Message(body='foo')
             ch.basic_publish(msg, exchange='', routing_key='kuyruk')
         worker.expect('Cannot decode message')
     self.assertEqual(len_queue('kuyruk'), 0)
예제 #10
0
 def test_worker_sigquit(self):
     """Ack current message and exit"""
     tasks.loop_forever()
     with run_kuyruk() as worker:
         worker.expect('looping forever')
         pid = get_pid('kuyruk: worker')
         os.kill(pid, signal.SIGUSR2)
         worker.expect('Dropping current task')
     assert len_queue("kuyruk") == 0, worker.get_output()
예제 #11
0
파일: test_worker.py 프로젝트: cenk/kuyruk
 def test_invalid_json(self):
     """Message is dropped when JSON is not valid"""
     with run_worker() as worker:
         worker.expect('Consumer started')
         with new_instance().channel() as ch:
             msg = amqp.Message(body='foo')
             ch.basic_publish(msg, exchange='', routing_key='kuyruk')
         worker.expect('Cannot decode message')
     self.assertEqual(len_queue('kuyruk'), 0)
예제 #12
0
 def test_worker_sigquit(self):
     """Ack current message and exit"""
     tasks.loop_forever()
     with run_kuyruk() as worker:
         worker.expect('looping forever')
         pid = get_pid('kuyruk: worker')
         os.kill(pid, signal.SIGUSR2)
         worker.expect('Dropping current task')
     assert len_queue("kuyruk") == 0, worker.get_output()
예제 #13
0
파일: test_worker.py 프로젝트: cenk/kuyruk
 def test_another_queue(self):
     """Task is run on another queue"""
     delete_queue('another_queue')
     tasks.echo_another('hello another')
     assert len_queue('another_queue') == 1
     with run_worker(queue='another_queue') as worker:
         worker.expect('Consumer started')
         worker.expect('hello another')
         worker.expect('Task is processed')
예제 #14
0
 def test_sigint(self):
     """Worker shuts down gracefully on SIGINT"""
     tasks.just_sleep(1)
     tasks.just_sleep(1)
     with run_worker(terminate=False) as worker:
         worker.expect('Processing task')
         worker.send_signal(signal.SIGINT)
         worker.expect('Task is successful')
         worker.expect_exit(0)
     assert len_queue("kuyruk") == 1, worker.get_output()
예제 #15
0
파일: test_worker.py 프로젝트: cenk/kuyruk
 def test_sigint(self):
     """Worker shuts down gracefully on SIGINT"""
     tasks.just_sleep(1)
     tasks.just_sleep(1)
     with run_worker(terminate=False) as worker:
         worker.expect('Processing task')
         worker.send_signal(signal.SIGINT)
         worker.expect('Task is successful')
         worker.expect_exit(0)
     assert len_queue("kuyruk") == 1, worker.get_output()
예제 #16
0
 def test_invalid_task_path(self):
     """Message is dropped when task cannot be imported"""
     with run_worker() as worker:
         worker.expect('Consumer started')
         with new_instance().channel() as ch:
             desc = {'module': 'kuyruk', 'function': 'foo'}
             body = json.dumps(desc)
             msg = amqp.Message(body=body)
             ch.basic_publish(msg, exchange='', routing_key='kuyruk')
         worker.expect('Cannot import task')
     self.assertEqual(len_queue('kuyruk'), 0)
예제 #17
0
파일: test_worker.py 프로젝트: cenk/kuyruk
 def test_invalid_task_path(self):
     """Message is dropped when task cannot be imported"""
     with run_worker() as worker:
         worker.expect('Consumer started')
         with new_instance().channel() as ch:
             desc = {'module': 'kuyruk', 'function': 'foo'}
             body = json.dumps(desc)
             msg = amqp.Message(body=body)
             ch.basic_publish(msg, exchange='', routing_key='kuyruk')
         worker.expect('Cannot import task')
     self.assertEqual(len_queue('kuyruk'), 0)
예제 #18
0
 def test_exception(self):
     """Errored task message is discarded"""
     tasks.raise_exception()
     with run_worker() as worker:
         worker.expect('ZeroDivisionError')
     assert len_queue("kuyruk") == 0
예제 #19
0
 def test_exception(self):
     """Errored task message is discarded"""
     tasks.raise_exception()
     with run_kuyruk() as worker:
         worker.expect('ZeroDivisionError')
     assert len_queue("kuyruk") == 0