Merge default heads published "concurrently"
authorDenis Laxalde <denis.laxalde@logilab.fr>
Thu, 03 Dec 2015 16:19:03 +0100
changeset 10947 1186757bc616
parent 10946 f7179ecfbae0 (current diff)
parent 10943 1079d68130e1 (diff)
child 10948 3ffacbdf7e9c
Merge default heads published "concurrently"
--- a/dataimport/pgstore.py	Thu Nov 26 14:23:38 2015 +0100
+++ b/dataimport/pgstore.py	Thu Dec 03 16:19:03 2015 +0100
@@ -31,6 +31,7 @@
 from six.moves import cPickle as pickle, range
 
 from cubicweb.utils import make_uid
+from cubicweb.server.utils import eschema_eid
 from cubicweb.server.sqlutils import SQL_PREFIX
 from cubicweb.dataimport.stores import NoHookRQLObjectStore
 
@@ -407,7 +408,7 @@
             _sql[statement] = [data]
 
     def add_entity(self, cnx, entity):
-        with self._storage_handler(entity, 'added'):
+        with self._storage_handler(cnx, entity, 'added'):
             attrs = self.preprocess_entity(entity)
             rtypes = self._inlined_rtypes_cache.get(entity.cw_etype, ())
             if isinstance(rtypes, str):
--- a/dataimport/test/test_pgstore.py	Thu Nov 26 14:23:38 2015 +0100
+++ b/dataimport/test/test_pgstore.py	Thu Dec 03 16:19:03 2015 +0100
@@ -24,6 +24,7 @@
 from logilab.common.testlib import TestCase, unittest_main
 
 from cubicweb.dataimport import pgstore
+from cubicweb.devtools import testlib
 
 
 class CreateCopyFromBufferTC(TestCase):
@@ -90,5 +91,16 @@
         expected = u'''42\téléphant\n6\tbabar'''
         self.assertEqual(expected, results.getvalue())
 
+
+class SQLGenObjectStoreTC(testlib.CubicWebTC):
+
+    def test_prepare_insert_entity(self):
+        with self.admin_access.repo_cnx() as cnx:
+            store = pgstore.SQLGenObjectStore(cnx)
+            eid = store.prepare_insert_entity('CWUser', login=u'toto',
+                                              upassword=u'pwd')
+            self.assertIsNotNone(eid)
+
+
 if __name__ == '__main__':
     unittest_main()