From e92b57d128f64eb974b23f551c2f1745033a7890 Mon Sep 17 00:00:00 2001 From: Javier Lopez Date: Mon, 16 May 2016 12:12:03 +0200 Subject: [PATCH] test_job.py: Add cancel test on failed queue --- tests/test_job.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/test_job.py b/tests/test_job.py index 30917ee..413039d 100644 --- a/tests/test_job.py +++ b/tests/test_job.py @@ -11,7 +11,7 @@ from tests.helpers import strip_microseconds from rq.compat import PY2, as_text from rq.exceptions import NoSuchJobError, UnpickleError from rq.job import Job, get_current_job, JobStatus, cancel_job -from rq.queue import Queue +from rq.queue import Queue, get_failed_queue from rq.registry import DeferredJobRegistry from rq.utils import utcformat from rq.worker import Worker @@ -435,3 +435,12 @@ class TestJob(RQTestCase): self.assertEqual(1, len(queue.get_jobs())) cancel_job(job.id) self.assertEqual(0, len(queue.get_jobs())) + + def test_create_failed_and_cancel_job(self): + """test creating and using cancel_job deletes job properly""" + failed = get_failed_queue(connection=self.testconn) + job = failed.enqueue(fixtures.say_hello) + job.set_status(JobStatus.FAILED) + self.assertEqual(1, len(failed.get_jobs())) + cancel_job(job.id) + self.assertEqual(0, len(failed.get_jobs()))