--- a/server/test/unittest_sqlutils.py Mon Sep 09 12:43:25 2013 +0200
+++ b/server/test/unittest_sqlutils.py Mon Dec 09 16:13:10 2013 +0100
@@ -1,4 +1,5 @@
-# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# -*- coding: utf-8 -*-
+# copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of CubicWeb.
@@ -24,6 +25,8 @@
from cubicweb.server.sqlutils import *
+from cubicweb.devtools.testlib import CubicWebTC
+
BASE_CONFIG = {
'db-driver' : 'Postgres',
'db-host' : 'crater',
@@ -44,5 +47,22 @@
o = SQLAdapterMixIn(config)
self.assertEqual(o.dbhelper.dbencoding, 'ISO-8859-1')
+
+class SQLUtilsTC(CubicWebTC):
+
+ def test_group_concat(self):
+ req = self.request()
+ g = req.create_entity('CWGroup', name=u'héhé')
+ u = req.create_entity('CWUser', login=u'toto', upassword=u'',
+ in_group=g.eid)
+ rset = self.execute(u'Any L,GROUP_CONCAT(G) GROUPBY L WHERE X login L,'
+ u'X in_group G, G name GN, NOT G name IN ("users", "héhé")')
+ self.assertEqual([[u'admin', u'3'], [u'anon', u'2']],
+ rset.rows)
+ rset = self.execute('Any L,GROUP_CONCAT(GN) GROUPBY L WHERE X login L,'
+ 'X in_group G, G name GN, NOT G name "users"')
+ self.assertEqual([[u'admin', u'managers'], [u'anon', u'guests'], [u'toto', u'héhé']],
+ rset.rows)
+
if __name__ == '__main__':
unittest_main()