diff --git a/rq/job.py b/rq/job.py index 4fb7355..c91c781 100644 --- a/rq/job.py +++ b/rq/job.py @@ -26,7 +26,7 @@ class Job(object): # Job construction @classmethod - def for_call(cls, func, *args, **kwargs): + def create(cls, func, *args, **kwargs): """Creates a new Job instance for the given function, arguments, and keyword arguments. """ diff --git a/rq/queue.py b/rq/queue.py index 2749787..15bc483 100644 --- a/rq/queue.py +++ b/rq/queue.py @@ -105,7 +105,7 @@ class Queue(object): 'Functions from the __main__ module cannot be processed ' 'by workers.') - job = Job.for_call(f, *args, **kwargs) + job = Job.create(f, *args, **kwargs) return self.enqueue_job(job) def enqueue_job(self, job, set_meta_data=True): diff --git a/tests/test_job.py b/tests/test_job.py index 78e2002..dc50e38 100644 --- a/tests/test_job.py +++ b/tests/test_job.py @@ -32,7 +32,7 @@ class TestJob(RQTestCase): def test_create_typical_job(self): """Creation of jobs for function calls.""" - job = Job.for_call(arbitrary_function, 3, 4, z=2) + job = Job.create(arbitrary_function, 3, 4, z=2) # Jobs have a random UUID self.assertIsNotNone(job.id) @@ -52,7 +52,7 @@ class TestJob(RQTestCase): def test_save(self): # noqa """Storing jobs.""" - job = Job.for_call(arbitrary_function, 3, 4, z=2) + job = Job.create(arbitrary_function, 3, 4, z=2) # Saving creates a Redis hash self.assertEquals(self.testconn.exists(job.key), False) @@ -98,7 +98,7 @@ class TestJob(RQTestCase): def test_persistence_of_typical_jobs(self): """Storing typical jobs.""" - job = Job.for_call(arbitrary_function, 3, 4, z=2) + job = Job.create(arbitrary_function, 3, 4, z=2) job.save() expected_date = strip_milliseconds(job.created_at) @@ -113,7 +113,7 @@ class TestJob(RQTestCase): ['created_at', 'data', 'description']) def test_store_then_fetch(self): - job = Job.for_call(arbitrary_function, 3, 4, z=2) + job = Job.create(arbitrary_function, 3, 4, z=2) job.save() job2 = Job.fetch(job.id) @@ -132,7 +132,7 @@ class TestJob(RQTestCase): def test_fetching_unreadable_data(self): """Fetching fails on unreadable data.""" # Set up - job = Job.for_call(arbitrary_function, 3, 4, z=2) + job = Job.create(arbitrary_function, 3, 4, z=2) job.save() # Just replace the data hkey with some random noise @@ -141,7 +141,7 @@ class TestJob(RQTestCase): job.refresh() # Set up (part B) - job = Job.for_call(arbitrary_function, 3, 4, z=2) + job = Job.create(arbitrary_function, 3, 4, z=2) job.save() # Now slightly modify the job to make it unpickl'able (this is diff --git a/tests/test_queue.py b/tests/test_queue.py index 4401aae..37f4151 100644 --- a/tests/test_queue.py +++ b/tests/test_queue.py @@ -85,7 +85,7 @@ class TestQueue(RQTestCase): def test_enqueue_sets_metadata(self): """Enqueueing job onto queues modifies meta data.""" q = Queue() - job = Job.for_call(testjob, 'Nick', foo='bar') + job = Job.create(testjob, 'Nick', foo='bar') # Preconditions self.assertIsNone(job.origin) @@ -195,7 +195,7 @@ class TestQueue(RQTestCase): class TestFailedQueue(RQTestCase): def test_requeue_job(self): """Requeueing existing jobs.""" - job = Job.for_call(failing_job, 1, 2, 3) + job = Job.create(failing_job, 1, 2, 3) job.origin = 'fake' job.save() FailedQueue().quarantine(job, Exception('Some fake error')) diff --git a/tests/test_worker.py b/tests/test_worker.py index 10091cd..bf3ae6a 100644 --- a/tests/test_worker.py +++ b/tests/test_worker.py @@ -41,7 +41,7 @@ class TestWorker(RQTestCase): # NOTE: We have to fake this enqueueing for this test case. # What we're simulating here is a call to a function that is not # importable from the worker process. - job = Job.for_call(failing_job, 3) + job = Job.create(failing_job, 3) job.save() data = self.testconn.hget(job.key, 'data') invalid_data = data.replace('failing_job', 'nonexisting_job')