From 07ea9015a21ecb5e292b155b5089dd76a0a338bc Mon Sep 17 00:00:00 2001 From: Selwin Ong Date: Sat, 14 Nov 2020 19:50:52 +0700 Subject: Updated test coverage --- tests/test_commands.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tests/test_commands.py b/tests/test_commands.py index 2970f6b..a7a0dd6 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -8,7 +8,6 @@ from tests.fixtures import long_running_job from rq import Queue, Worker from rq.command import send_command, send_kill_horse_command, send_shutdown_command, send_stop_job_command from rq.exceptions import InvalidJobOperation, NoSuchJobError -from rq.job import Job, JobStatus from rq.worker import WorkerStatus @@ -47,6 +46,19 @@ class TestCommands(RQTestCase): job.refresh() self.assertTrue(job.id in queue.failed_job_registry) + def start_work(): + worker.work() + + p = Process(target=start_work) + p.start() + p.join(2) + + send_kill_horse_command(connection, worker.name) + worker.refresh() + # Since worker is not busy, command will be ignored + self.assertEqual(worker.get_state(), WorkerStatus.IDLE) + send_shutdown_command(connection, worker.name) + def test_stop_job_command(self): """Ensure that stop_job command works properly.""" @@ -82,4 +94,4 @@ class TestCommands(RQTestCase): time.sleep(0.25) # Worker has stopped working worker.refresh() - self.assertEqual(worker.get_state(), WorkerStatus.IDLE) \ No newline at end of file + self.assertEqual(worker.get_state(), WorkerStatus.IDLE) -- cgit v1.2.1