diff --git a/rq/queue.py b/rq/queue.py index 14c4a5e..02308e0 100644 --- a/rq/queue.py +++ b/rq/queue.py @@ -352,7 +352,6 @@ class Queue(object): def __hash__(self): return hash(self.name) - def __repr__(self): # noqa return 'Queue(%r)' % (self.name,) @@ -362,7 +361,7 @@ class Queue(object): class FailedQueue(Queue): def __init__(self, connection=None): - super(FailedQueue, self).__init__('failed', connection=connection) + super(FailedQueue, self).__init__(Status.FAILED, connection=connection) def quarantine(self, job, exc_info): """Puts the given Job in quarantine (i.e. put it on the failed diff --git a/rq/worker.py b/rq/worker.py index 64fd904..69b54a1 100644 --- a/rq/worker.py +++ b/rq/worker.py @@ -325,7 +325,7 @@ class Worker(object): self.connection.expire(self.key, (job.timeout or Queue.DEFAULT_TIMEOUT) + 60) self.fork_and_perform_job(job) self.connection.expire(self.key, self.default_worker_ttl) - if job.status == 'finished': + if job.status == Status.FINISHED: queue.enqueue_dependents(job) did_perform_work = True diff --git a/tests/test_queue.py b/tests/test_queue.py index 0f0ea26..75a97db 100644 --- a/tests/test_queue.py +++ b/tests/test_queue.py @@ -316,7 +316,7 @@ class TestQueue(RQTestCase): self.assertEqual(q.job_ids, []) # Jobs dependent on finished jobs are immediately enqueued - parent_job.status = 'finished' + parent_job.status = Status.FINISHED parent_job.save() job = q.enqueue_call(say_hello, depends_on=parent_job) self.assertEqual(q.job_ids, [job.id]) @@ -332,7 +332,7 @@ class TestQueue(RQTestCase): self.assertEqual(job.timeout, 123) # Jobs dependent on finished jobs are immediately enqueued - parent_job.status = 'finished' + parent_job.status = Status.FINISHED parent_job.save() job = q.enqueue_call(say_hello, depends_on=parent_job, timeout=123) self.assertEqual(q.job_ids, [job.id]) diff --git a/tests/test_worker.py b/tests/test_worker.py index fe77c04..7a6cfa7 100644 --- a/tests/test_worker.py +++ b/tests/test_worker.py @@ -214,14 +214,14 @@ class TestWorker(RQTestCase): w = Worker([q]) job = q.enqueue(say_hello) - self.assertEqual(job.status, 'queued') + self.assertEqual(job.status, Status.QUEUED) self.assertEqual(job.is_queued, True) self.assertEqual(job.is_finished, False) self.assertEqual(job.is_failed, False) w.work(burst=True) job = Job.fetch(job.id) - self.assertEqual(job.status, 'finished') + self.assertEqual(job.status, Status.FINISHED) self.assertEqual(job.is_queued, False) self.assertEqual(job.is_finished, True) self.assertEqual(job.is_failed, False) @@ -230,7 +230,7 @@ class TestWorker(RQTestCase): job = q.enqueue(div_by_zero, args=(1,)) w.work(burst=True) job = Job.fetch(job.id) - self.assertEqual(job.status, 'failed') + self.assertEqual(job.status, Status.FAILED) self.assertEqual(job.is_queued, False) self.assertEqual(job.is_finished, False) self.assertEqual(job.is_failed, True) @@ -243,10 +243,10 @@ class TestWorker(RQTestCase): job = q.enqueue_call(say_hello, depends_on=parent_job) w.work(burst=True) job = Job.fetch(job.id) - self.assertEqual(job.status, 'finished') + self.assertEqual(job.status, Status.FINISHED) parent_job = q.enqueue(div_by_zero) job = q.enqueue_call(say_hello, depends_on=parent_job) w.work(burst=True) job = Job.fetch(job.id) - self.assertNotEqual(job.status, 'finished') + self.assertNotEqual(job.status, Status.FINISHED)