def test_atomic_rw_hash_user_abort(self): def evaluator(x): return None Redis.hset('dqtest-rwh', 'key', 'meow') succ, no_error = Redis.atomic_rw_hash('dqtest-rwh', 'key', evaluator) assert not succ and no_error assert Redis.hget('dqtest-rwh', 'key') == 'meow' Redis.delete('dqtest-rwh')
def test_atomic_rw_hash(self): def evaluator(x): return x + '#1' Redis.hset('dqtest-rwh', 'key', 'cornell ') succ, no_error = Redis.atomic_rw_hash('dqtest-rwh', 'key', evaluator) assert succ and no_error assert Redis.hget('dqtest-rwh', 'key') == 'cornell #1' Redis.delete('dqtest-rwh')
def test_atomic_rw_hash_error(self): def change(): Redis.hset('dqtest-rwh', 'key', 'meow2') def evaluator(x): t = threading.Thread(target=change) t.start() sleep(0.5) return x + '#1' Redis.hset('dqtest-rwh', 'key', 'meow') succ, no_error = Redis.atomic_rw_hash('dqtest-rwh', 'key', evaluator) assert not succ and not no_error assert Redis.hget('dqtest-rwh', 'key') == 'meow2' Redis.delete('dqtest-rwh')