From 3a8f30a53ec3447c3fdb34552eacd0985b3a028b Mon Sep 17 00:00:00 2001 From: Vincent Driessen Date: Wed, 18 Jul 2012 14:03:28 +0200 Subject: [PATCH] Add test. --- tests/test_job.py | 11 ++++++++++- tests/test_worker.py | 9 +++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/tests/test_job.py b/tests/test_job.py index 1a5916bf..111c3f32 100644 --- a/tests/test_job.py +++ b/tests/test_job.py @@ -58,6 +58,15 @@ class TestJob(RQTestCase): self.assertEquals(job.instance, c) 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 """Storing jobs.""" job = Job.create(some_calculation, 3, 4, z=2) @@ -176,7 +185,7 @@ class TestJob(RQTestCase): job.foo = 'bar' job.save() self.assertEqual(self.testconn.hget(job.key, 'foo'), 'bar') - + job2 = Job.fetch(job.id) job2.refresh() self.assertEqual(job2.foo, 'bar') diff --git a/tests/test_worker.py b/tests/test_worker.py index 27f3b25b..9cd8aa26 100644 --- a/tests/test_worker.py +++ b/tests/test_worker.py @@ -25,6 +25,15 @@ class TestWorker(RQTestCase): self.assertEquals(w.work(burst=True), True, '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): """Unreadable jobs are put on the failed queue.""" q = Queue()