dataimport/test/test_massive_store.py
changeset 10872 ff4f94cfa2fb
parent 10869 575982c948a9
child 10875 75d1b2d66f18
equal deleted inserted replaced
10871:1d4a94d04ec6 10872:ff4f94cfa2fb
   151         self.assertIn('unique_entities_extid_idx', indexes)
   151         self.assertIn('unique_entities_extid_idx', indexes)
   152         self.assertIn('owned_by_relation_p_key', indexes)
   152         self.assertIn('owned_by_relation_p_key', indexes)
   153         self.assertIn('owned_by_relation_to_idx', indexes)
   153         self.assertIn('owned_by_relation_to_idx', indexes)
   154 
   154 
   155     def test_eids_seq_range(self):
   155     def test_eids_seq_range(self):
   156         with self.admin_access.repo_cnx() as cnx:
   156         class MyMassiveObjectStore(MassiveObjectStore):
   157             store = MassiveObjectStore(cnx, eids_seq_range=1000, eids_seq_start=50000)
   157             eids_seq_range = 1000
       
   158             eids_seq_start = 50000
       
   159 
       
   160         with self.admin_access.repo_cnx() as cnx:
       
   161             store = MyMassiveObjectStore(cnx)
   158             store.prepare_insert_entity('Location', name=u'toto')
   162             store.prepare_insert_entity('Location', name=u'toto')
   159             store.flush()
   163             store.flush()
   160             cnx.commit()
   164             cnx.commit()
   161         with self.admin_access.repo_cnx() as cnx:
   165         with self.admin_access.repo_cnx() as cnx:
   162             crs = cnx.system_sql("SELECT * FROM entities_id_seq")
   166             crs = cnx.system_sql("SELECT * FROM entities_id_seq")
   163             self.assertGreater(crs.fetchone()[0], 50000)
   167             self.assertGreater(crs.fetchone()[0], 50000)
   164 
   168 
   165     def test_eid_entity(self):
   169     def test_eid_entity(self):
   166         with self.admin_access.repo_cnx() as cnx:
   170         class MyMassiveObjectStore(MassiveObjectStore):
   167             store = MassiveObjectStore(cnx, eids_seq_range=1000, eids_seq_start=50000)
   171             eids_seq_range = 1000
       
   172             eids_seq_start = 50000
       
   173 
       
   174         with self.admin_access.repo_cnx() as cnx:
       
   175             store = MyMassiveObjectStore(cnx)
   168             eid = store.prepare_insert_entity('Location', name=u'toto')
   176             eid = store.prepare_insert_entity('Location', name=u'toto')
   169             store.flush()
   177             store.flush()
   170             self.assertGreater(eid, 50000)
   178             self.assertGreater(eid, 50000)
   171 
   179 
   172     def test_eid_entity_2(self):
   180     def test_eid_entity_2(self):
   173         with self.admin_access.repo_cnx() as cnx:
   181         class MyMassiveObjectStore(MassiveObjectStore):
   174             store = MassiveObjectStore(cnx, eids_seq_range=1000, eids_seq_start=50000)
   182             eids_seq_range = 1000
       
   183             eids_seq_start = 50000
       
   184 
       
   185         with self.admin_access.repo_cnx() as cnx:
       
   186             store = MyMassiveObjectStore(cnx)
   175             eid = store.prepare_insert_entity('Location', name=u'toto', eid=10000)
   187             eid = store.prepare_insert_entity('Location', name=u'toto', eid=10000)
   176             store.flush()
   188             store.flush()
   177         self.assertEqual(eid, 10000)
   189         self.assertEqual(eid, 10000)
   178 
   190 
   179     def test_on_commit_callback(self):
   191     def test_on_commit_callback(self):