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