Skip to content

Commit

Permalink
Merge 94a7798 into 43c9279
Browse files Browse the repository at this point in the history
  • Loading branch information
jlucas91 committed Oct 20, 2017
2 parents 43c9279 + 94a7798 commit c0c3486
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
3 changes: 2 additions & 1 deletion rq/decorators.py
Expand Up @@ -44,8 +44,9 @@ def delay(*args, **kwargs):
else:
queue = self.queue
depends_on = kwargs.pop('depends_on', None)
meta = kwargs.pop('meta', None)
return queue.enqueue_call(f, args=args, kwargs=kwargs,
timeout=self.timeout, result_ttl=self.result_ttl,
ttl=self.ttl, depends_on=depends_on)
ttl=self.ttl, depends_on=depends_on, meta=meta)
f.delay = delay
return f
17 changes: 17 additions & 0 deletions tests/test_decorator.py
Expand Up @@ -92,6 +92,23 @@ def bar():

self.assertEqual(bar_job._dependency_id, foo_job.id)

def test_decorator_accepts_metaas_argument(self):
"""Ensure that passing in meta to the decorator sets the
meta on the job correctly.
"""

@job(queue='queue_name')
def hello():
return 'Hello'

test_meta = {
'metaKey1': 1,
'metaKey2': 2,
}

result = hello.delay(meta=test_meta)
self.assertEqual(result.meta, test_meta)

@mock.patch('rq.queue.resolve_connection')
def test_decorator_connection_laziness(self, resolve_connection):
"""Ensure that job decorator resolve connection in `lazy` way """
Expand Down

0 comments on commit c0c3486

Please sign in to comment.