示例#1
0
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'])
示例#2
0
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
示例#3
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
示例#4
0
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'])
示例#5
0
 def fin():
     get_redis_conn().delete('test_sorted_set')
示例#6
0
 def fin():
     try:
         get_redis_conn().delete(model.key)
     except Exception:
         pass
示例#7
0
 def fin():
     get_redis_conn().delete(model.key)
示例#8
0
 def fin():
     get_redis_conn().delete('test_set_2')
示例#9
0
 def fin():
     get_redis_conn().delete('test_hashset')
示例#10
0
 def fin():
     get_redis_conn().delete('test_list')