diff --git a/test/test_celery_worker_global.py b/test/test_celery_worker_global.py index dd840d3f9e1ab189a974e48c0ab6d159fbbb3172..a67d07c47665ca9f97f0a51f4654103b34574fda 100644 --- a/test/test_celery_worker_global.py +++ b/test/test_celery_worker_global.py @@ -6,6 +6,8 @@ import contextlib import os from inventory_provider.tasks import worker +from inventory_provider.tasks import common + from inventory_provider.tasks.common import _get_redis @@ -50,7 +52,26 @@ def test_update_locations(mocker, mocked_worker_module, mocked_redis): def test_InventoryTask_obj(data_config_filename): - os.environ['INVENTORY_PROVIDER_CONFIG_FILENAME'] = data_config_filename task = worker.InventoryTask() assert task.config + + +def test_next_redis(data_config, mocked_redis): + common.set_latch(data_config, 10, 20) + r = common.get_next_redis(data_config) + assert r + + # there's only one ... + latch = common.get_latch(r) + assert latch['current'] == 10 + assert latch['next'] == 20 + + +def test_next_redis_with_none(data_config, mocked_redis): + r = common._get_redis(data_config) + assert r + + del r.db['db:latch'] # cf. conftest:MockedRedis + r = common.get_next_redis(data_config) + assert r