|
|
@ -88,9 +88,9 @@ class TestJob(RQTestCase):
|
|
|
|
"""Fetching jobs."""
|
|
|
|
"""Fetching jobs."""
|
|
|
|
# Prepare test
|
|
|
|
# Prepare test
|
|
|
|
self.testconn.hset('rq:job:some_id', 'data',
|
|
|
|
self.testconn.hset('rq:job:some_id', 'data',
|
|
|
|
"(S'tests.fixtures.some_calculation'\nN(I3\nI4\nt(dp1\nS'z'\nI2\nstp2\n.") # noqa
|
|
|
|
"(S'tests.fixtures.some_calculation'\nN(I3\nI4\nt(dp1\nS'z'\nI2\nstp2\n.")
|
|
|
|
self.testconn.hset('rq:job:some_id', 'created_at',
|
|
|
|
self.testconn.hset('rq:job:some_id', 'created_at',
|
|
|
|
"2012-02-07 22:13:24+0000")
|
|
|
|
'2012-02-07 22:13:24+0000')
|
|
|
|
|
|
|
|
|
|
|
|
# Fetch returns a job
|
|
|
|
# Fetch returns a job
|
|
|
|
job = Job.fetch('some_id')
|
|
|
|
job = Job.fetch('some_id')
|
|
|
@ -195,12 +195,12 @@ class TestJob(RQTestCase):
|
|
|
|
"""Ensure that job's result_ttl is set properly"""
|
|
|
|
"""Ensure that job's result_ttl is set properly"""
|
|
|
|
job = Job.create(func=say_hello, args=('Lionel',), result_ttl=10)
|
|
|
|
job = Job.create(func=say_hello, args=('Lionel',), result_ttl=10)
|
|
|
|
job.save()
|
|
|
|
job.save()
|
|
|
|
job_from_queue = Job.fetch(job.id, connection=self.testconn)
|
|
|
|
Job.fetch(job.id, connection=self.testconn)
|
|
|
|
self.assertEqual(job.result_ttl, 10)
|
|
|
|
self.assertEqual(job.result_ttl, 10)
|
|
|
|
|
|
|
|
|
|
|
|
job = Job.create(func=say_hello, args=('Lionel',))
|
|
|
|
job = Job.create(func=say_hello, args=('Lionel',))
|
|
|
|
job.save()
|
|
|
|
job.save()
|
|
|
|
job_from_queue = Job.fetch(job.id, connection=self.testconn)
|
|
|
|
Job.fetch(job.id, connection=self.testconn)
|
|
|
|
self.assertEqual(job.result_ttl, None)
|
|
|
|
self.assertEqual(job.result_ttl, None)
|
|
|
|
|
|
|
|
|
|
|
|
def test_description_is_persisted(self):
|
|
|
|
def test_description_is_persisted(self):
|
|
|
@ -208,13 +208,13 @@ class TestJob(RQTestCase):
|
|
|
|
description = 'Say hello!'
|
|
|
|
description = 'Say hello!'
|
|
|
|
job = Job.create(func=say_hello, args=('Lionel',), description=description)
|
|
|
|
job = Job.create(func=say_hello, args=('Lionel',), description=description)
|
|
|
|
job.save()
|
|
|
|
job.save()
|
|
|
|
job_from_queue = Job.fetch(job.id, connection=self.testconn)
|
|
|
|
Job.fetch(job.id, connection=self.testconn)
|
|
|
|
self.assertEqual(job.description, description)
|
|
|
|
self.assertEqual(job.description, description)
|
|
|
|
|
|
|
|
|
|
|
|
# Ensure job description is constructed from function call string
|
|
|
|
# Ensure job description is constructed from function call string
|
|
|
|
job = Job.create(func=say_hello, args=('Lionel',))
|
|
|
|
job = Job.create(func=say_hello, args=('Lionel',))
|
|
|
|
job.save()
|
|
|
|
job.save()
|
|
|
|
job_from_queue = Job.fetch(job.id, connection=self.testconn)
|
|
|
|
Job.fetch(job.id, connection=self.testconn)
|
|
|
|
self.assertEqual(job.description, job.get_call_string())
|
|
|
|
self.assertEqual(job.description, job.get_call_string())
|
|
|
|
|
|
|
|
|
|
|
|
def test_job_access_within_job_function(self):
|
|
|
|
def test_job_access_within_job_function(self):
|
|
|
|