(caplog, arq_redis: ArqRedis)
| 75 | |
| 76 | |
| 77 | async def test_handle_sig(caplog, arq_redis: ArqRedis): |
| 78 | caplog.set_level(logging.INFO) |
| 79 | worker = Worker([foobar], redis_pool=arq_redis) |
| 80 | worker.main_task = MagicMock() |
| 81 | worker.tasks = {0: MagicMock(done=MagicMock(return_value=True)), 1: MagicMock(done=MagicMock(return_value=False))} |
| 82 | |
| 83 | assert len(caplog.records) == 0 |
| 84 | worker.handle_sig(signal.SIGINT) |
| 85 | assert len(caplog.records) == 1 |
| 86 | assert caplog.records[0].message == ( |
| 87 | 'shutdown on SIGINT ◆ 0 jobs complete ◆ 0 failed ◆ 0 retries ◆ 2 ongoing to cancel' |
| 88 | ) |
| 89 | assert worker.main_task.cancel.call_count == 1 |
| 90 | assert worker.tasks[0].done.call_count == 1 |
| 91 | assert worker.tasks[0].cancel.call_count == 0 |
| 92 | assert worker.tasks[1].done.call_count == 1 |
| 93 | assert worker.tasks[1].cancel.call_count == 1 |
| 94 | |
| 95 | |
| 96 | async def test_handle_no_sig(caplog): |
nothing calls this directly
no test coverage detected
searching dependent graphs…