diff options
| author | Selwin Ong <selwin.ong@gmail.com> | 2020-11-14 19:50:52 +0700 |
|---|---|---|
| committer | Selwin Ong <selwin.ong@gmail.com> | 2020-11-14 19:50:52 +0700 |
| commit | 07ea9015a21ecb5e292b155b5089dd76a0a338bc (patch) | |
| tree | e36bff09d1ec6581042d00a0f76091ed75d001ff | |
| parent | 8f23af5606f214bdaac259597cb3d1eec7936ee0 (diff) | |
| download | rq-stop-job.tar.gz | |
Updated test coveragestop-job
| -rw-r--r-- | tests/test_commands.py | 16 |
1 files 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) |
