Esempio n. 1
0
    def __init__(self):
        location = utils.get_lock_location()
        if location is None or location == '':
            raise ValueError(
                'Redis server location must be set in the settings file.')

        self.redis_obj = Redis.from_url(location)
        self.storage_lock = self.redis_obj.lock(
            name=utils.get_lock_name(),
            timeout=utils.get_lock_time_to_live(
            ),  # Time before lock is forcefully released.
            blocking_timeout=utils.get_lock_timeout(),
        )
Esempio n. 2
0
def test_get_lock_location_host_and_port():
    location = utils.get_lock_location()
    assert location == 'testname:1234'
Esempio n. 3
0
def test_get_lock_location_only_host():
    location = utils.get_lock_location()
    assert location == 'testname'
Esempio n. 4
0
def test_get_lock_location_default():
    location = utils.get_lock_location()
    assert location == 'Redis://localhost:6379/1'