server/test/unittest_sqlutils.py
branchstable
changeset 9334 ea12401c0a68
parent 6340 470d8e828fda
child 9335 7da91456be2c
--- a/server/test/unittest_sqlutils.py	Thu Oct 24 18:28:18 2013 +0200
+++ b/server/test/unittest_sqlutils.py	Thu Nov 28 18:55:24 2013 +0100
@@ -24,6 +24,8 @@
 
 from cubicweb.server.sqlutils import *
 
+from cubicweb.devtools.testlib import CubicWebTC
+
 BASE_CONFIG = {
     'db-driver' : 'Postgres',
     'db-host'   : 'crater',
@@ -44,5 +46,17 @@
         o = SQLAdapterMixIn(config)
         self.assertEqual(o.dbhelper.dbencoding, 'ISO-8859-1')
 
+
+class SQLUtilsTC(CubicWebTC):
+
+    def test_group_concat(self):
+        req = self.request()
+        u = req.create_entity('CWUser', login=u'toto', upassword=u'',
+                              in_group=req.execute('CWGroup G WHERE G name "managers"').rows[0][0])
+        rset = self.execute('Any L,GROUP_CONCAT(G) GROUPBY L WHERE X login L,'
+                            'X in_group G, G name GN, NOT G name "users"')
+        self.assertEqual([[u'admin', u'3'], [u'anon', u'2'], [u'toto', u'3']],
+                         rset.rows)
+
 if __name__ == '__main__':
     unittest_main()