From 7275f62737f94bf0638a98a2c634015f07546ea2 Mon Sep 17 00:00:00 2001 From: Antoine Leclair Date: Mon, 15 Feb 2016 22:32:06 -0500 Subject: [PATCH] Add tests for custom job class in worker --- tests/test_worker.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/test_worker.py b/tests/test_worker.py index 56d0717..18ce901 100644 --- a/tests/test_worker.py +++ b/tests/test_worker.py @@ -347,6 +347,22 @@ class TestWorker(RQTestCase): worker = Worker([q], job_class=CustomJob) self.assertEqual(worker.job_class, CustomJob) + def test_custom_job_class_by_string(self): + """Ensure Worker accepts custom job class using dotted notation.""" + q = Queue() + worker = Worker([q], job_class='test_worker.CustomJob') + self.assertEqual(worker.job_class, CustomJob) + + def test_custom_job_class_is_not_global(self): + """Ensure Worker custom job class is not global.""" + q = Queue() + worker_custom = Worker([q], job_class=CustomJob) + q_generic = Queue() + worker_generic = Worker([q_generic]) + self.assertEqual(worker_custom.job_class, CustomJob) + self.assertEqual(worker_generic.job_class, Job) + self.assertEqual(Worker.job_class, Job) + def test_work_via_simpleworker(self): """Worker processes work, with forking disabled, then returns."""