Merge pull request #765 from jsurloppe/master

Fix get job on failed queue
main
Selwin Ong 8 years ago committed by GitHub
commit f4e7783abf

@ -111,7 +111,7 @@ class Queue(object):
except NoSuchJobError: except NoSuchJobError:
self.remove(job_id) self.remove(job_id)
else: else:
if job.origin == self.name: if job.origin == self.name or (job.is_failed and self == get_failed_queue(connection=self.connection)):
return job return job
def get_job_ids(self, offset=0, length=-1): def get_job_ids(self, offset=0, length=-1):

@ -505,6 +505,27 @@ class TestFailedQueue(RQTestCase):
self.assertEqual(get_failed_queue().count, 0) self.assertEqual(get_failed_queue().count, 0)
self.assertEqual(Queue('fake').count, 1) self.assertEqual(Queue('fake').count, 1)
def test_get_job_on_failed_queue(self):
default_queue = Queue()
failed_queue = get_failed_queue()
job = default_queue.enqueue(div_by_zero, args=(1, 2, 3))
job_on_default_queue = default_queue.fetch_job(job.id)
job_on_failed_queue = failed_queue.fetch_job(job.id)
self.assertIsNotNone(job_on_default_queue)
self.assertIsNone(job_on_failed_queue)
job.set_status(JobStatus.FAILED)
job_on_default_queue = default_queue.fetch_job(job.id)
job_on_failed_queue = failed_queue.fetch_job(job.id)
self.assertIsNotNone(job_on_default_queue)
self.assertIsNotNone(job_on_failed_queue)
self.assertTrue(job_on_default_queue.is_failed)
def test_requeue_nonfailed_job_fails(self): def test_requeue_nonfailed_job_fails(self):
"""Requeueing non-failed jobs raises error.""" """Requeueing non-failed jobs raises error."""
q = Queue() q = Queue()

Loading…
Cancel
Save