|
|
|
@ -80,24 +80,19 @@ class TestRQCli(RQTestCase):
|
|
|
|
|
q = Queue()
|
|
|
|
|
failed_q = get_failed_queue()
|
|
|
|
|
failed_q.empty()
|
|
|
|
|
# Preconditions
|
|
|
|
|
self.assertEquals(failed_q.count, 0)
|
|
|
|
|
self.assertEquals(q.count, 0)
|
|
|
|
|
|
|
|
|
|
# Action
|
|
|
|
|
job = q.enqueue(div_by_zero)
|
|
|
|
|
self.assertEquals(q.count, 1)
|
|
|
|
|
|
|
|
|
|
runner = CliRunner()
|
|
|
|
|
result = runner.invoke(main, ['worker', '-u', self.redis_url, '-b', '--exception-handler', 'tests.fixtures.black_hole'])
|
|
|
|
|
self.assertEqual(result.exit_code, 0)
|
|
|
|
|
# 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)
|
|
|
|
|
|
|
|
|
|
# If exception handler is not given, failed job goes to FailedQueue
|
|
|
|
|
q.enqueue(div_by_zero)
|
|
|
|
|
runner.invoke(main, ['worker', '-u', self.redis_url, '-b'])
|
|
|
|
|
self.assertEquals(failed_q.count, 1)
|
|
|
|
|
|
|
|
|
|
# Black hole exception handler doesn't add failed jobs to FailedQueue
|
|
|
|
|
q.enqueue(div_by_zero)
|
|
|
|
|
runner.invoke(main, ['worker', '-u', self.redis_url, '-b',
|
|
|
|
|
'--exception-handler', 'tests.fixtures.black_hole'])
|
|
|
|
|
self.assertEquals(failed_q.count, 1)
|
|
|
|
|
|
|
|
|
|
def test_suspend_and_resume(self):
|
|
|
|
|
"""rq suspend -u <url>
|
|
|
|
|