Exemplo n.º 1
0
 def test01_get_all_query(self):
     ''' Test getAll '''
     res = Query("test").execute()
     self.assert_equal(res.count(), self.N)
     for k in range(self.N):
         item = res[k]
         self.assert_equal(item['param1'], k)
         self.assert_equal(item['param2'], "value%d" % k)
         self.assert_equal(item['param3'], (k%2==0))
Exemplo n.º 2
0
 def refresh(self):
     ''' Sync this object with its persisted version '''
     if not self._new:
         res = Query(self._col_name).where(_id=self.get_id()).execute()
         if not res or not res.count():
             raise Exception("%s does not exist any more" % self)
         o = res[0]
         for field in o:
             setattr(self, field, o[field])