Esempio n. 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())    
Esempio n. 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())
Esempio n. 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())  
Esempio n. 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())
Esempio n. 5
0
 def test_put_memcache(self):  
   model = TestModel(key_name='test_key_name',name='test')
   key = pdb.put(model,_storage='memcache')
   entity = _deserialize(memcache.get(str(key)))
   self.assertEqual('test', entity.name)
Esempio n. 6
0
 def test_delete_memcache(self):  
   pdb.delete(self.setup_key,_storage='memcache')
   entity = _deserialize(memcache.get(self.cache_key))
   self.assertEqual(entity , None)
Esempio n. 7
0
 def test_put_memcache(self):
     model = TestModel(key_name='test_key_name', name='test')
     key = pdb.put(model, _storage='memcache')
     entity = _deserialize(memcache.get(str(key)))
     self.assertEqual('test', entity.name)
Esempio n. 8
0
 def test_delete_memcache(self):
     pdb.delete(self.setup_key, _storage='memcache')
     entity = _deserialize(memcache.get(self.cache_key))
     self.assertEqual(entity, None)