Merge pull request #451 from conslo/depend-on-unsaved-job-ids

Depend on unsaved job ids
This commit is contained in:
Selwin Ong 2014-11-26 08:33:05 +07:00
commit 2091c601b1
2 changed files with 2 additions and 4 deletions

View File

@ -190,7 +190,7 @@ class Queue(object):
# modifying the dependency. In this case we simply retry
if depends_on is not None:
if not isinstance(depends_on, self.job_class):
depends_on = Job.fetch(id=depends_on, connection=self.connection)
depends_on = Job(id=depends_on, connection=self.connection)
with self.connection.pipeline() as pipe:
while True:
try:

View File

@ -355,9 +355,7 @@ class TestQueue(RQTestCase):
def test_enqueue_job_with_dependency_by_id(self):
"""Enqueueing jobs should work as expected by id as well as job-objects."""
parent_job = Job.create(func=say_hello)
# We need to save the job for the ID to exist in redis
parent_job.save()
q = Queue()
q.enqueue_call(say_hello, depends_on=parent_job.id)
self.assertEqual(q.job_ids, [])