예제 #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')