|
|
|
@ -96,6 +96,34 @@ class TestWorker(RQTestCase):
|
|
|
|
|
self.assertEquals(job.enqueued_at, enqueued_at_date)
|
|
|
|
|
self.assertIsNotNone(job.exc_info) # should contain exc_info
|
|
|
|
|
|
|
|
|
|
def test_custom_exc_handling(self):
|
|
|
|
|
"""Custom exception handling."""
|
|
|
|
|
def black_hole(job, *exc_info):
|
|
|
|
|
# Don't fall through to default behaviour (moving to failed queue)
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
q = Queue()
|
|
|
|
|
failed_q = get_failed_queue()
|
|
|
|
|
|
|
|
|
|
# Preconditions
|
|
|
|
|
self.assertEquals(failed_q.count, 0)
|
|
|
|
|
self.assertEquals(q.count, 0)
|
|
|
|
|
|
|
|
|
|
# Action
|
|
|
|
|
job = q.enqueue(div_by_zero)
|
|
|
|
|
self.assertEquals(q.count, 1)
|
|
|
|
|
|
|
|
|
|
w = Worker([q], exc_handler=black_hole)
|
|
|
|
|
w.work(burst=True) # should silently pass
|
|
|
|
|
|
|
|
|
|
# Postconditions
|
|
|
|
|
self.assertEquals(q.count, 0)
|
|
|
|
|
self.assertEquals(failed_q.count, 0)
|
|
|
|
|
|
|
|
|
|
# Check the job
|
|
|
|
|
job = Job.fetch(job.id)
|
|
|
|
|
self.assertEquals(job.is_failed, True)
|
|
|
|
|
|
|
|
|
|
def test_cancelled_jobs_arent_executed(self): # noqa
|
|
|
|
|
"""Cancelling jobs."""
|
|
|
|
|
|
|
|
|
|