dataimport/test/test_massive_store.py
changeset 10860 252877c624f0
parent 10858 1a3e56e346d2
child 10863 8e1f6de61300
equal deleted inserted replaced
10859:375a8232e61c 10860:252877c624f0
   170             store.create_entity('Location', name=u'toto')
   170             store.create_entity('Location', name=u'toto')
   171             store.flush()
   171             store.flush()
   172             cnx.commit()
   172             cnx.commit()
   173         with self.admin_access.repo_cnx() as cnx:
   173         with self.admin_access.repo_cnx() as cnx:
   174             crs = cnx.system_sql("SELECT * FROM entities_id_seq")
   174             crs = cnx.system_sql("SELECT * FROM entities_id_seq")
   175             self.assertTrue(crs.fetchone()[0] > 50000)
   175             self.assertGreater(crs.fetchone()[0], 50000)
   176 
   176 
   177     def test_eid_entity(self):
   177     def test_eid_entity(self):
   178         with self.admin_access.repo_cnx() as cnx:
   178         with self.admin_access.repo_cnx() as cnx:
   179             store = MassiveObjectStore(cnx, eids_seq_range=1000, eids_seq_start=50000)
   179             store = MassiveObjectStore(cnx, eids_seq_range=1000, eids_seq_start=50000)
   180             entity = store.create_entity('Location', name=u'toto')
   180             entity = store.create_entity('Location', name=u'toto')
   181             store.flush()
   181             store.flush()
   182             self.assertTrue(entity.eid > 50000)
   182             self.assertGreater(entity.eid, 50000)
   183 
   183 
   184     def test_eid_entity_2(self):
   184     def test_eid_entity_2(self):
   185         with self.admin_access.repo_cnx() as cnx:
   185         with self.admin_access.repo_cnx() as cnx:
   186             store = MassiveObjectStore(cnx, eids_seq_range=1000, eids_seq_start=50000)
   186             store = MassiveObjectStore(cnx, eids_seq_range=1000, eids_seq_start=50000)
   187             entity = store.create_entity('Location', name=u'toto', eid=10000)
   187             entity = store.create_entity('Location', name=u'toto', eid=10000)
   188             store.flush()
   188             store.flush()
   189         with self.admin_access.repo_cnx() as cnx:
   189         with self.admin_access.repo_cnx() as cnx:
   190             self.assertTrue(entity.eid==10000)
   190             self.assertEqual(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=lambda:next(counter))
   195             store = MassiveObjectStore(cnx, on_commit_callback=lambda:next(counter))