[test] Add test for dataimport's RQLObjectStore
authorJulien Cristau <julien.cristau@logilab.fr>
Wed, 09 Jul 2014 15:35:28 +0200
changeset 9909 e2d42ad10f98
parent 9908 88bbb3abf30f
child 9910 55d9d483e7c3
[test] Add test for dataimport's RQLObjectStore
test/unittest_dataimport.py
--- a/test/unittest_dataimport.py	Wed Jul 09 16:00:21 2014 +0200
+++ b/test/unittest_dataimport.py	Wed Jul 09 15:35:28 2014 +0200
@@ -3,6 +3,26 @@
 from StringIO import StringIO
 from logilab.common.testlib import TestCase, unittest_main
 from cubicweb import dataimport
+from cubicweb.devtools.testlib import CubicWebTC
+
+
+class RQLObjectStoreTC(CubicWebTC):
+
+    def test_all(self):
+        with self.admin_access.repo_cnx() as cnx:
+            store = dataimport.RQLObjectStore(cnx)
+            group_eid = store.create_entity('CWGroup', name=u'grp').eid
+            user_eid = store.create_entity('CWUser', login=u'lgn', upassword=u'pwd').eid
+            store.relate(user_eid, 'in_group', group_eid)
+            cnx.commit()
+
+        with self.admin_access.repo_cnx() as cnx:
+            users = cnx.execute('CWUser X WHERE X login "lgn"')
+            self.assertEqual(1, len(users))
+            self.assertEqual(user_eid, users.one().eid)
+            groups = cnx.execute('CWGroup X WHERE U in_group X, U login "lgn"')
+            self.assertEqual(1, len(users))
+            self.assertEqual(group_eid, groups.one().eid)
 
 class CreateCopyFromBufferTC(TestCase):