summaryrefslogtreecommitdiff
path: root/tests/test_cli.py
diff options
context:
space:
mode:
authorSelwin Ong <selwin.ong@gmail.com>2023-03-23 11:23:50 +0700
committerSelwin Ong <selwin.ong@gmail.com>2023-03-23 11:23:50 +0700
commita4a74ee377b97b8b7ce57b020c45b21ede56cff2 (patch)
treeef4c0e7c1c62f485f00f7b85277beecaf515c120 /tests/test_cli.py
parent63ed6216043ba2b5c3d18703d9945b0ecb25259e (diff)
parent04722339d7598ff0c52f11c3680ed2dd922e6768 (diff)
downloadrq-watcher.tar.gz
Merge branch 'master' of github.com:rq/rq into watcherwatcher
Diffstat (limited to 'tests/test_cli.py')
-rw-r--r--tests/test_cli.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/test_cli.py b/tests/test_cli.py
index 07b9c39..daa118b 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -5,6 +5,7 @@ from uuid import uuid4
import os
import json
+from click import BadParameter
from click.testing import CliRunner
from redis import Redis
@@ -14,6 +15,7 @@ from rq.cli.helpers import read_config_file, CliConfig, parse_function_arg, pars
from rq.job import Job
from rq.registry import FailedJobRegistry, ScheduledJobRegistry
from rq.serializers import JSONSerializer
+from rq.timeouts import UnixSignalDeathPenalty
from rq.worker import Worker, WorkerStatus
from rq.scheduler import RQScheduler
@@ -118,6 +120,23 @@ class TestRQCli(RQTestCase):
'testhost.example.com',
)
+ def test_death_penalty_class(self):
+ cli_config = CliConfig()
+
+ self.assertEqual(
+ UnixSignalDeathPenalty,
+ cli_config.death_penalty_class
+ )
+
+ cli_config = CliConfig(death_penalty_class='rq.job.Job')
+ self.assertEqual(
+ Job,
+ cli_config.death_penalty_class
+ )
+
+ with self.assertRaises(BadParameter):
+ CliConfig(death_penalty_class='rq.abcd')
+
def test_empty_nothing(self):
"""rq empty -u <url>"""
runner = CliRunner()
@@ -326,6 +345,21 @@ class TestRQCli(RQTestCase):
result = runner.invoke(main, args + ['--quiet', '--verbose'])
self.assertNotEqual(result.exit_code, 0)
+ def test_worker_dequeue_strategy(self):
+ """--quiet and --verbose logging options are supported"""
+ runner = CliRunner()
+ args = ['worker', '-u', self.redis_url, '-b', '--dequeue-strategy', 'random']
+ result = runner.invoke(main, args)
+ self.assert_normal_execution(result)
+
+ args = ['worker', '-u', self.redis_url, '-b', '--dequeue-strategy', 'round_robin']
+ result = runner.invoke(main, args)
+ self.assert_normal_execution(result)
+
+ args = ['worker', '-u', self.redis_url, '-b', '--dequeue-strategy', 'wrong']
+ result = runner.invoke(main, args)
+ self.assertEqual(result.exit_code, 1)
+
def test_exception_handlers(self):
"""rq worker -u <url> -b --exception-handler <handler>"""
connection = Redis.from_url(self.redis_url)