def test_model_save(model): assert len(get_redis_conn().keys(model.key)) == 0 save(model) assert len(get_redis_conn().keys(model.key)) == 1 db_model = get_redis_conn().hgetall(model.key) assert db_model is not None assert model.test_str_1 == json.loads(db_model['t1']) assert model.test_str_2 == json.loads(db_model['t2']) assert model.test_str_3 == json.loads(db_model['t3'])
def test_delete_in_transaction(saved_model, saved_list_model): t = TestListModel(saved_list_model.key) load(t) t.l.append(saved_model.key) save(t) t = TestListModel(saved_list_model.key) load(t) assert len(t.l) == 1 delete_in_transaction_fn() db_model = get_redis_conn().hgetall(saved_model.key) assert len(db_model.keys()) == 0 saved_list_db_model = get_redis_conn().hgetall(saved_list_model.key) assert len(json.loads(saved_list_db_model['l'])) == 0
def test_model_load(saved_model): assert len(get_redis_conn().keys(saved_model.key)) == 1 loaded_model = TestModel('test_model_1') load(loaded_model) assert loaded_model.test_str_1 == saved_model.test_str_1 assert loaded_model.test_str_2 == saved_model.test_str_2 assert loaded_model.test_str_3 == saved_model.test_str_3
def test_simple_transaction(saved_model): simple_transaction_fn() db_model = get_redis_conn().hgetall(saved_model.key) assert db_model is not None assert "blah blah" == json.loads(db_model['t1'])
def fin(): get_redis_conn().delete('test_sorted_set')
def fin(): try: get_redis_conn().delete(model.key) except Exception: pass
def fin(): get_redis_conn().delete(model.key)
def fin(): get_redis_conn().delete('test_set_2')
def fin(): get_redis_conn().delete('test_hashset')
def fin(): get_redis_conn().delete('test_list')