Add test.

main
Vincent Driessen 13 years ago
parent 84988bdf94
commit 3a8f30a53e

@ -58,6 +58,15 @@ class TestJob(RQTestCase):
self.assertEquals(job.instance, c) self.assertEquals(job.instance, c)
self.assertEquals(job.args, (3, 4)) self.assertEquals(job.args, (3, 4))
def test_create_job_from_string_function(self):
"""Creation of jobs using string specifier."""
job = Job.create('tests.fixtures.say_hello', 'World')
# Job data is set
self.assertEquals(job.func, say_hello)
self.assertIsNone(job.instance)
self.assertEquals(job.args, ('World',))
def test_save(self): # noqa def test_save(self): # noqa
"""Storing jobs.""" """Storing jobs."""
job = Job.create(some_calculation, 3, 4, z=2) job = Job.create(some_calculation, 3, 4, z=2)
@ -176,7 +185,7 @@ class TestJob(RQTestCase):
job.foo = 'bar' job.foo = 'bar'
job.save() job.save()
self.assertEqual(self.testconn.hget(job.key, 'foo'), 'bar') self.assertEqual(self.testconn.hget(job.key, 'foo'), 'bar')
job2 = Job.fetch(job.id) job2 = Job.fetch(job.id)
job2.refresh() job2.refresh()
self.assertEqual(job2.foo, 'bar') self.assertEqual(job2.foo, 'bar')

@ -25,6 +25,15 @@ class TestWorker(RQTestCase):
self.assertEquals(w.work(burst=True), True, self.assertEquals(w.work(burst=True), True,
'Expected at least some work done.') 'Expected at least some work done.')
def test_work_via_string_argument(self):
"""Worker processes work fed via string arguments."""
q = Queue('foo')
w = Worker([q])
result = q.enqueue('tests.fixtures.say_hello', name='Frank')
self.assertEquals(w.work(burst=True), True,
'Expected at least some work done.')
self.assertEquals(result.return_value, 'Hi there, Frank!')
def test_work_is_unreadable(self): def test_work_is_unreadable(self):
"""Unreadable jobs are put on the failed queue.""" """Unreadable jobs are put on the failed queue."""
q = Queue() q = Queue()

Loading…
Cancel
Save