diff --git a/tests/test_queue.py b/tests/test_queue.py index cb3193d..081af75 100644 --- a/tests/test_queue.py +++ b/tests/test_queue.py @@ -307,24 +307,36 @@ class TestQueue(RQTestCase): self.assertEqual(q.job_ids, [job_1.id, job_2.id]) self.assertFalse(self.testconn.exists(parent_job.waitlist_key)) - def test_enqueue_job_with_dependency(self, timeout=None): - """Jobs are enqueued only when their dependencies are finished""" + def test_enqueue_job_with_dependency(self): + """Jobs are enqueued only when their dependencies are finished.""" # Job with unfinished dependency is not immediately enqueued parent_job = Job.create(func=say_hello) q = Queue() - job = q.enqueue_call(say_hello, after=parent_job, timeout=timeout) + q.enqueue_call(say_hello, after=parent_job) self.assertEqual(q.job_ids, []) - self.assertEqual(job.timeout, timeout) # Jobs dependent on finished jobs are immediately enqueued parent_job.status = 'finished' parent_job.save() - job = q.enqueue_call(say_hello, after=parent_job, timeout=timeout) + job = q.enqueue_call(say_hello, after=parent_job) self.assertEqual(q.job_ids, [job.id]) - self.assertEqual(job.timeout, Queue.DEFAULT_TIMEOUT if timeout is None else timeout) + self.assertEqual(job.timeout, Queue.DEFAULT_TIMEOUT) def test_enqueue_job_with_dependency_and_timeout(self): - self.test_enqueue_job_with_dependency(123) + """Jobs still know their specified timeout after being scheduled as a dependency.""" + # Job with unfinished dependency is not immediately enqueued + parent_job = Job.create(func=say_hello) + q = Queue() + job = q.enqueue_call(say_hello, after=parent_job, timeout=123) + self.assertEqual(q.job_ids, []) + self.assertEqual(job.timeout, 123) + + # Jobs dependent on finished jobs are immediately enqueued + parent_job.status = 'finished' + parent_job.save() + job = q.enqueue_call(say_hello, after=parent_job, timeout=123) + self.assertEqual(q.job_ids, [job.id]) + self.assertEqual(job.timeout, 123) class TestFailedQueue(RQTestCase):