示例#1
0
  def test_get(self):
    db_entity = self.query.get(_cache=['local','memcache'])
    cache_key = self.query.key_name
    memcache_entity = _deserialize(memcache.get(cache_key))[0]
    local_entity = cachepy.get(cache_key)[0]
 
    self.assertEqual(db_entity.count,0)
    self.assertEqual(db_entity.key(),memcache_entity.key())
    self.assertEqual(memcache_entity.key(),local_entity.key())      
    
    db_entity = self.query.get(offset=50,_cache=['local','memcache'])
    cache_key = self.query.key_name
    memcache_entity = _deserialize(memcache.get(cache_key))[0]
    local_entity = cachepy.get(cache_key)[0]
    
    self.assertEqual(db_entity.count,50)
    self.assertEqual(db_entity.key(),memcache_entity.key())
    self.assertEqual(memcache_entity.key(),local_entity.key())    
示例#2
0
    def test_get(self):
        db_entity = self.query.get(_cache=["local", "memcache"])
        cache_key = self.query.key_name
        memcache_entity = _deserialize(memcache.get(cache_key))[0]
        local_entity = cachepy.get(cache_key)[0]

        self.assertEqual(db_entity.count, 0)
        self.assertEqual(db_entity.key(), memcache_entity.key())
        self.assertEqual(memcache_entity.key(), local_entity.key())

        db_entity = self.query.get(offset=50, _cache=["local", "memcache"])
        cache_key = self.query.key_name
        memcache_entity = _deserialize(memcache.get(cache_key))[0]
        local_entity = cachepy.get(cache_key)[0]

        self.assertEqual(db_entity.count, 50)
        self.assertEqual(db_entity.key(), memcache_entity.key())
        self.assertEqual(memcache_entity.key(), local_entity.key())
示例#3
0
 def test_fetch(self):
   db_models = self.query.fetch(100,_cache=['local','memcache'])
   cache_key = self.query.key_name
   memcache_models = _deserialize(memcache.get(cache_key))
   local_models = cachepy.get(cache_key)
   
   self.assertEqual(len(db_models),100)
   self.assertEqual(len(memcache_models),100)
   self.assertEqual(len(local_models),100)
   self.assertEqual(db_models[0].key(),memcache_models[0].key())
   self.assertEqual(db_models[0].key(),local_models[0].key())      
   
   db_models = self.query.fetch(100,offset=50,_cache=['local','memcache'])
   cache_key = self.query.key_name
   memcache_models = _deserialize(memcache.get(cache_key))
   local_models = cachepy.get(cache_key)
   
   self.assertEqual(len(db_models),50)
   self.assertEqual(len(memcache_models),50)
   self.assertEqual(len(local_models),50)
   self.assertEqual(db_models[0].key(),memcache_models[0].key())
   self.assertEqual(db_models[0].key(),local_models[0].key())  
示例#4
0
    def test_fetch(self):
        db_models = self.query.fetch(100, _cache=["local", "memcache"])
        cache_key = self.query.key_name
        memcache_models = _deserialize(memcache.get(cache_key))
        local_models = cachepy.get(cache_key)

        self.assertEqual(len(db_models), 100)
        self.assertEqual(len(memcache_models), 100)
        self.assertEqual(len(local_models), 100)
        self.assertEqual(db_models[0].key(), memcache_models[0].key())
        self.assertEqual(db_models[0].key(), local_models[0].key())

        db_models = self.query.fetch(100, offset=50, _cache=["local", "memcache"])
        cache_key = self.query.key_name
        memcache_models = _deserialize(memcache.get(cache_key))
        local_models = cachepy.get(cache_key)

        self.assertEqual(len(db_models), 50)
        self.assertEqual(len(memcache_models), 50)
        self.assertEqual(len(local_models), 50)
        self.assertEqual(db_models[0].key(), memcache_models[0].key())
        self.assertEqual(db_models[0].key(), local_models[0].key())
示例#5
0
 def test_delete_local(self):
   pdb.delete(self.setup_key,_storage='local')
   entity = cachepy.get(self.cache_key)
   self.assertEqual(entity , None)
示例#6
0
 def test_put_local(self):
   model = TestModel(key_name='test_key_name',name='test')
   key = pdb.put(model,_storage='local')
   entity = cachepy.get(str(key))
   self.assertEqual('test', entity.name)
示例#7
0
 def test_delete_local(self):
     pdb.delete(self.setup_key, _storage='local')
     entity = cachepy.get(self.cache_key)
     self.assertEqual(entity, None)
示例#8
0
 def test_put_local(self):
     model = TestModel(key_name='test_key_name', name='test')
     key = pdb.put(model, _storage='local')
     entity = cachepy.get(str(key))
     self.assertEqual('test', entity.name)