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(), )
def test_get_lock_location_host_and_port(): location = utils.get_lock_location() assert location == 'testname:1234'
def test_get_lock_location_only_host(): location = utils.get_lock_location() assert location == 'testname'
def test_get_lock_location_default(): location = utils.get_lock_location() assert location == 'Redis://localhost:6379/1'