| 1 |
import operator |
| 2 |
from unittest.mock import Mock |
| 3 |
|
| 4 |
from celery import signals |
| 5 |
from celery.concurrency import solo |
| 6 |
from celery.utils.functional import noop |
| 7 |
|
| 8 |
|
| 9 |
class test_solo_TaskPool: |
| 10 |
|
| 11 |
def test_on_start(self): |
| 12 |
x = solo.TaskPool() |
| 13 |
x.on_start() |
| 14 |
|
| 15 |
def test_on_apply(self): |
| 16 |
x = solo.TaskPool() |
| 17 |
x.on_start() |
| 18 |
x.on_apply(operator.add, (2, 2), {}, noop, noop) |
| 19 |
|
| 20 |
def test_info(self): |
| 21 |
x = solo.TaskPool() |
| 22 |
x.on_start() |
| 23 |
assert x.info |
| 24 |
|
| 25 |
def test_on_worker_process_init_called(self): |
| 26 |
"""Upon the initialization of a new solo worker pool a worker_process_init |
| 27 |
signal should be emitted""" |
| 28 |
on_worker_process_init = Mock() |
| 29 |
signals.worker_process_init.connect(on_worker_process_init) |
| 30 |
solo.TaskPool() |
| 31 |
assert on_worker_process_init.call_count == 1 |