equal
deleted
inserted
replaced
22 |
22 |
23 from logilab.common.testlib import TestCase, unittest_main |
23 from logilab.common.testlib import TestCase, unittest_main |
24 |
24 |
25 from cubicweb.server.sqlutils import * |
25 from cubicweb.server.sqlutils import * |
26 |
26 |
|
27 from cubicweb.devtools.testlib import CubicWebTC |
|
28 |
27 BASE_CONFIG = { |
29 BASE_CONFIG = { |
28 'db-driver' : 'Postgres', |
30 'db-driver' : 'Postgres', |
29 'db-host' : 'crater', |
31 'db-host' : 'crater', |
30 'db-name' : 'cubicweb2_test', |
32 'db-name' : 'cubicweb2_test', |
31 'db-user' : 'toto', |
33 'db-user' : 'toto', |
42 config = BASE_CONFIG.copy() |
44 config = BASE_CONFIG.copy() |
43 config['db-encoding'] = 'ISO-8859-1' |
45 config['db-encoding'] = 'ISO-8859-1' |
44 o = SQLAdapterMixIn(config) |
46 o = SQLAdapterMixIn(config) |
45 self.assertEqual(o.dbhelper.dbencoding, 'ISO-8859-1') |
47 self.assertEqual(o.dbhelper.dbencoding, 'ISO-8859-1') |
46 |
48 |
|
49 |
|
50 class SQLUtilsTC(CubicWebTC): |
|
51 |
|
52 def test_group_concat(self): |
|
53 req = self.request() |
|
54 u = req.create_entity('CWUser', login=u'toto', upassword=u'', |
|
55 in_group=req.execute('CWGroup G WHERE G name "managers"').rows[0][0]) |
|
56 rset = self.execute('Any L,GROUP_CONCAT(G) GROUPBY L WHERE X login L,' |
|
57 'X in_group G, G name GN, NOT G name "users"') |
|
58 self.assertEqual([[u'admin', u'3'], [u'anon', u'2'], [u'toto', u'3']], |
|
59 rset.rows) |
|
60 |
47 if __name__ == '__main__': |
61 if __name__ == '__main__': |
48 unittest_main() |
62 unittest_main() |