示例#1
0
    def test_get(self):
        local_entity = PdbModel.get(self.setup_key, _storage='local')
        memcache_entity = PdbModel.get(self.setup_key, _storage='memcache')
        db_entity = PdbModel.get(self.setup_key, _storage='datastore')

        self.assertEqual(local_entity.name, self.setup_name)
        self.assertEqual(memcache_entity.name, self.setup_name)
        self.assertEqual(db_entity.name, self.setup_name)
示例#2
0
 def test_get(self):  
   local_entity = PdbModel.get(self.setup_key,_storage='local')
   memcache_entity = PdbModel.get(self.setup_key,_storage='memcache')
   db_entity = PdbModel.get(self.setup_key,_storage='datastore')
   
   self.assertEqual(local_entity.name,self.setup_name)
   self.assertEqual(memcache_entity.name,self.setup_name)
   self.assertEqual(db_entity.name,self.setup_name)
示例#3
0
 def test_delete(self):
   model = PdbModel.get(self.setup_key,_storage=['local','memcache','datastore'])
   model.delete(_storage=['local','memcache','datastore'])
   
   local_entity = PdbModel.get(self.setup_key,_storage='local')
   memcache_entity = PdbModel.get(self.setup_key,_storage='memcache')
   db_entity = PdbModel.get(self.setup_key,_storage='datastore')
   
   self.assertEqual(local_entity , None)
   self.assertEqual(memcache_entity , None)
   self.assertEqual(db_entity , None)
示例#4
0
 def test_put(self):
   model = PdbModel(name='put_test')
   key = model.put(_storage=['local','memcache','datastore'])
   
   local_entity = PdbModel.get(key,_storage='local')
   memcache_entity = PdbModel.get(key,_storage='memcache')
   db_entity = PdbModel.get(key,_storage='datastore')
   
   self.assertEqual(local_entity.name,'put_test')
   self.assertEqual(memcache_entity.name,'put_test')
   self.assertEqual(db_entity.name,'put_test')                
示例#5
0
    def test_delete(self):
        model = PdbModel.get(self.setup_key,
                             _storage=['local', 'memcache', 'datastore'])
        model.delete(_storage=['local', 'memcache', 'datastore'])

        local_entity = PdbModel.get(self.setup_key, _storage='local')
        memcache_entity = PdbModel.get(self.setup_key, _storage='memcache')
        db_entity = PdbModel.get(self.setup_key, _storage='datastore')

        self.assertEqual(local_entity, None)
        self.assertEqual(memcache_entity, None)
        self.assertEqual(db_entity, None)
示例#6
0
    def test_get_by_id(self):
        local_entity = PdbModel.get_by_id(self.setup_key_int.id(),
                                          parent=self.parent_key,
                                          _storage='local')
        memcache_entity = PdbModel.get_by_id(self.setup_key_int.id(),
                                             parent=self.parent_key,
                                             _storage='memcache')
        db_entity = PdbModel.get_by_id(self.setup_key_int.id(),
                                       parent=self.parent_key,
                                       _storage='datastore')

        self.assertEqual(local_entity.name, self.setup_name_int)
        self.assertEqual(memcache_entity.name, self.setup_name_int)
        self.assertEqual(db_entity.name, self.setup_name_int)
示例#7
0
  def test_get_by_id(self):
    local_entity = PdbModel.get_by_id(self.setup_key_int.id(),
                                      parent = self.parent_key,
                                      _storage='local')
    memcache_entity = PdbModel.get_by_id(self.setup_key_int.id(),
                                         parent = self.parent_key,
                                         _storage='memcache')
    db_entity = PdbModel.get_by_id(self.setup_key_int.id(),
                                   parent = self.parent_key,
                                   _storage='datastore')

    self.assertEqual(local_entity.name,self.setup_name_int)
    self.assertEqual(memcache_entity.name,self.setup_name_int)
    self.assertEqual(db_entity.name,self.setup_name_int)
 def setUp(self):
     self.testbed = testbed.Testbed()
     self.testbed.activate()
     self.testbed.init_datastore_v3_stub()
     self.testbed.init_memcache_stub()
     self.entity = PdbModel(key_name='test')
     self.time = datetime(2011, 1, 1, 0, 0, 0)
示例#9
0
 def setUp(self):
     self.testbed = testbed.Testbed()
     self.testbed.activate()
     self.testbed.init_datastore_v3_stub()
     self.testbed.init_memcache_stub()
     self.setup_name = 'test'
     self.setup_name_int = 'int_model'
     parent_model = PdbModel(key_name='parent_model')
     model = PdbModel(key_name='test_model',
                      parent=parent_model,
                      name=self.setup_name)
     int_model = PdbModel(name=self.setup_name_int, parent=parent_model)
     self.setup_key = pdb.put(model,
                              _storage=['local', 'memcache', 'datastore'])
     self.parent_key = pdb.put(parent_model,
                               _storage=['local', 'memcache', 'datastore'])
     self.setup_key_int = pdb.put(
         int_model, _storage=['local', 'memcache', 'datastore'])
示例#10
0
 def setUp(self):
   self.testbed = testbed.Testbed()
   self.testbed.activate()
   self.testbed.init_datastore_v3_stub()
   self.testbed.init_memcache_stub()
   self.query = pdb.GqlQuery('SELECT * FROM PdbModel')
   models = []
   for i in range(100):
     models.append(PdbModel(count=i))
     
   pdb.put(models)
示例#11
0
    def test_get_or_insert(self):
        #Existing entity
        local_entity = PdbModel.get_or_insert(self.setup_key.name(),
                                              parent=self.parent_key,
                                              name='Different name',
                                              _storage='local')
        memcache_entity = PdbModel.get_or_insert(self.setup_key.name(),
                                                 parent=self.parent_key,
                                                 name='Different name',
                                                 _storage='memcache')
        db_entity = PdbModel.get_or_insert(self.setup_key.name(),
                                           parent=self.parent_key,
                                           name='Different name',
                                           _storage='datastore')

        self.assertEqual(local_entity.name, self.setup_name)
        self.assertEqual(memcache_entity.name, self.setup_name)
        self.assertEqual(db_entity.name, self.setup_name)

        #New entity
        key_name = 'new_entity'
        local_entity = PdbModel.get_or_insert(key_name,
                                              name='Different name',
                                              _storage='local')
        memcache_entity = PdbModel.get_or_insert(key_name,
                                                 name='Different name',
                                                 _storage='memcache')
        db_entity = PdbModel.get_or_insert(key_name,
                                           name='Different name',
                                           _storage='datastore')

        self.assertEqual(local_entity.name, 'Different name')
        self.assertEqual(memcache_entity.name, 'Different name')
        self.assertEqual(db_entity.name, 'Different name')
示例#12
0
  def test_get_or_insert(self):
    #Existing entity
    local_entity = PdbModel.get_or_insert(self.setup_key.name(),
                                          parent = self.parent_key,
                                          name='Different name'
                                          ,_storage='local')
    memcache_entity = PdbModel.get_or_insert(self.setup_key.name(),
                                             parent = self.parent_key,
                                             name='Different name',
                                             _storage='memcache')
    db_entity = PdbModel.get_or_insert(self.setup_key.name(),
                                       parent = self.parent_key,
                                       name='Different name',
                                       _storage='datastore')

    self.assertEqual(local_entity.name,self.setup_name)
    self.assertEqual(memcache_entity.name,self.setup_name)
    self.assertEqual(db_entity.name,self.setup_name)
    
    #New entity
    key_name = 'new_entity'
    local_entity = PdbModel.get_or_insert(key_name,
                                          name='Different name'
                                          ,_storage='local')
    memcache_entity = PdbModel.get_or_insert(key_name,
                                             name='Different name',
                                             _storage='memcache')
    db_entity = PdbModel.get_or_insert(key_name,
                                       name='Different name',
                                       _storage='datastore')

    self.assertEqual(local_entity.name,'Different name')
    self.assertEqual(memcache_entity.name,'Different name')
    self.assertEqual(db_entity.name,'Different name')
示例#13
0
    def test_put(self):
        model = PdbModel(name='put_test')
        key = model.put(_storage=['local', 'memcache', 'datastore'])

        local_entity = PdbModel.get(key, _storage='local')
        memcache_entity = PdbModel.get(key, _storage='memcache')
        db_entity = PdbModel.get(key, _storage='datastore')

        self.assertEqual(local_entity.name, 'put_test')
        self.assertEqual(memcache_entity.name, 'put_test')
        self.assertEqual(db_entity.name, 'put_test')