|
|
@ -273,20 +273,26 @@ class TestWorker(RQTestCase):
|
|
|
|
q = Queue()
|
|
|
|
q = Queue()
|
|
|
|
job = q.enqueue(say_hello, args=('Frank',), result_ttl=10)
|
|
|
|
job = q.enqueue(say_hello, args=('Frank',), result_ttl=10)
|
|
|
|
w = Worker([q])
|
|
|
|
w = Worker([q])
|
|
|
|
|
|
|
|
self.assertIn(job.get_id().encode('utf-8'), self.testconn.lrange(q.key, 0, -1))
|
|
|
|
w.work(burst=True)
|
|
|
|
w.work(burst=True)
|
|
|
|
self.assertNotEqual(self.testconn._ttl(job.key), 0)
|
|
|
|
self.assertNotEqual(self.testconn._ttl(job.key), 0)
|
|
|
|
|
|
|
|
self.assertNotIn(job.get_id().encode('utf-8'), self.testconn.lrange(q.key, 0, -1))
|
|
|
|
|
|
|
|
|
|
|
|
# Job with -1 result_ttl don't expire
|
|
|
|
# Job with -1 result_ttl don't expire
|
|
|
|
job = q.enqueue(say_hello, args=('Frank',), result_ttl=-1)
|
|
|
|
job = q.enqueue(say_hello, args=('Frank',), result_ttl=-1)
|
|
|
|
w = Worker([q])
|
|
|
|
w = Worker([q])
|
|
|
|
|
|
|
|
self.assertIn(job.get_id().encode('utf-8'), self.testconn.lrange(q.key, 0, -1))
|
|
|
|
w.work(burst=True)
|
|
|
|
w.work(burst=True)
|
|
|
|
self.assertEqual(self.testconn._ttl(job.key), -1)
|
|
|
|
self.assertEqual(self.testconn._ttl(job.key), -1)
|
|
|
|
|
|
|
|
self.assertNotIn(job.get_id().encode('utf-8'), self.testconn.lrange(q.key, 0, -1))
|
|
|
|
|
|
|
|
|
|
|
|
# Job with result_ttl = 0 gets deleted immediately
|
|
|
|
# Job with result_ttl = 0 gets deleted immediately
|
|
|
|
job = q.enqueue(say_hello, args=('Frank',), result_ttl=0)
|
|
|
|
job = q.enqueue(say_hello, args=('Frank',), result_ttl=0)
|
|
|
|
w = Worker([q])
|
|
|
|
w = Worker([q])
|
|
|
|
|
|
|
|
self.assertIn(job.get_id().encode('utf-8'), self.testconn.lrange(q.key, 0, -1))
|
|
|
|
w.work(burst=True)
|
|
|
|
w.work(burst=True)
|
|
|
|
self.assertEqual(self.testconn.get(job.key), None)
|
|
|
|
self.assertEqual(self.testconn.get(job.key), None)
|
|
|
|
|
|
|
|
self.assertNotIn(job.get_id().encode('utf-8'), self.testconn.lrange(q.key, 0, -1))
|
|
|
|
|
|
|
|
|
|
|
|
def test_worker_sets_job_status(self):
|
|
|
|
def test_worker_sets_job_status(self):
|
|
|
|
"""Ensure that worker correctly sets job status."""
|
|
|
|
"""Ensure that worker correctly sets job status."""
|
|
|
|