diff options
author | Bradley Young <young.bradley@gmail.com> | 2014-11-12 09:04:40 -0500 |
---|---|---|
committer | Bradley Young <young.bradley@gmail.com> | 2014-11-12 09:04:40 -0500 |
commit | 5caccaabfe213e98a5a03a6f5914662d8c322134 (patch) | |
tree | 7edb9807dac4d0ceeb6e7230c715140508ba6390 /tests/test_cli.py | |
parent | 0dbe68527ce029b5fd0a51d229344322d81f149e (diff) | |
download | rq-5caccaabfe213e98a5a03a6f5914662d8c322134.tar.gz |
Adding optional list handling to the exc_handler option in Worker.
Adding command line --exception_handler option (with multiple entries allowed) to `rq worker`
Added tests for command line options.
Diffstat (limited to 'tests/test_cli.py')
-rw-r--r-- | tests/test_cli.py | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/tests/test_cli.py b/tests/test_cli.py index a92fb34..fad684a 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -3,7 +3,7 @@ from __future__ import (absolute_import, division, print_function, unicode_literals) from click.testing import CliRunner -from rq import get_failed_queue +from rq import get_failed_queue, Queue from rq.compat import is_python_version from rq.job import Job from rq.cli import main @@ -63,3 +63,27 @@ class TestRQCli(RQTestCase): runner = CliRunner() result = runner.invoke(main, ['worker', '-u', self.redis_url, '-b']) self.assertEqual(result.exit_code, 0) + + def test_exc_handler(self): + """rq worker -u <url> -b --exception-handler <handler>""" + q = Queue() + failed_q = get_failed_queue() + failed_q.empty() + # Preconditions + self.assertEquals(failed_q.count, 0) + self.assertEquals(q.count, 0) + + # Action + job = q.enqueue(div_by_zero) + self.assertEquals(q.count, 1) + + runner = CliRunner() + result = runner.invoke(main, ['worker', '-u', self.redis_url, '-b', '--exception-handler', 'tests.fixtures.black_hole']) + self.assertEqual(result.exit_code, 0) + # Postconditions + self.assertEquals(q.count, 0) + self.assertEquals(failed_q.count, 0) + + # Check the job + job = Job.fetch(job.id) + self.assertEquals(job.is_failed, True) |