dataimport/test/test_massive_store.py
changeset 10855 cd91f46fa633
parent 10853 de741492538d
child 10857 aa490912d9da
equal deleted inserted replaced
10854:f437787d8849 10855:cd91f46fa633
   190             self.assertTrue(entity.eid==10000)
   190             self.assertTrue(entity.eid==10000)
   191 
   191 
   192     def test_on_commit_callback(self):
   192     def test_on_commit_callback(self):
   193         counter = itertools.count()
   193         counter = itertools.count()
   194         with self.admin_access.repo_cnx() as cnx:
   194         with self.admin_access.repo_cnx() as cnx:
   195             store = MassiveObjectStore(cnx, on_commit_callback=counter.next)
   195             store = MassiveObjectStore(cnx, on_commit_callback=lambda:next(counter))
   196             store.create_entity('Location', name=u'toto')
   196             store.create_entity('Location', name=u'toto')
   197             store.flush()
   197             store.flush()
   198             store.commit()
   198             store.commit()
   199         self.assertTrue(counter.next() >= 1)
   199         self.assertGreaterEqual(next(counter), 1)
   200 
   200 
   201     def test_on_rollback_callback(self):
   201     def test_on_rollback_callback(self):
   202         counter = itertools.count()
   202         counter = itertools.count()
   203         with self.admin_access.repo_cnx() as cnx:
   203         with self.admin_access.repo_cnx() as cnx:
   204             store = MassiveObjectStore(cnx, on_rollback_callback=lambda *_: counter.next())
   204             store = MassiveObjectStore(cnx, on_rollback_callback=lambda *_: next(counter))
   205             store.create_entity('Location', nm='toto')
   205             store.create_entity('Location', nm='toto')
   206             store.flush()
   206             store.flush()
   207             store.commit()
   207             store.commit()
   208         self.assertTrue(counter.next() >= 1)
   208         self.assertGreaterEqual(next(counter), 1)
   209 
   209 
   210     def test_slave_mode_indexes(self):
   210     def test_slave_mode_indexes(self):
   211         with self.admin_access.repo_cnx() as cnx:
   211         with self.admin_access.repo_cnx() as cnx:
   212             slave_store = MassiveObjectStore(cnx, slave_mode=True)
   212             slave_store = MassiveObjectStore(cnx, slave_mode=True)
   213         with self.admin_access.repo_cnx() as cnx:
   213         with self.admin_access.repo_cnx() as cnx: