server/test/unittest_querier.py
branchstable
changeset 6050 20af96a6fffc
parent 5811 e77cea9721e7
child 6081 ede33e6400ab
child 6189 9fa02f352c8c
equal deleted inserted replaced
6049:f0ae98fa85a1 6050:20af96a6fffc
   834         self.failUnlessEqual(rset.description[0][1], 'Interval')
   834         self.failUnlessEqual(rset.description[0][1], 'Interval')
   835         eid, = self.execute("INSERT Personne X: X nom 'bidule'")[0]
   835         eid, = self.execute("INSERT Personne X: X nom 'bidule'")[0]
   836         rset = self.execute('Any X, NOW - CD WHERE X is Personne, X creation_date CD')
   836         rset = self.execute('Any X, NOW - CD WHERE X is Personne, X creation_date CD')
   837         self.failUnlessEqual(rset.description[0][1], 'Interval')
   837         self.failUnlessEqual(rset.description[0][1], 'Interval')
   838 
   838 
   839     def test_select_subquery_aggregat(self):
   839     def test_select_subquery_aggregat_1(self):
   840         # percent users by groups
   840         # percent users by groups
   841         self.execute('SET X in_group G WHERE G name "users"')
   841         self.execute('SET X in_group G WHERE G name "users"')
   842         rset = self.execute('Any GN, COUNT(X)*100/T GROUPBY GN ORDERBY 2,1'
   842         rset = self.execute('Any GN, COUNT(X)*100/T GROUPBY GN ORDERBY 2,1'
   843                             ' WHERE G name GN, X in_group G'
   843                             ' WHERE G name GN, X in_group G'
   844                             ' WITH T BEING (Any COUNT(U) WHERE U is CWUser)')
   844                             ' WITH T BEING (Any COUNT(U) WHERE U is CWUser)')
   845         self.assertEquals(rset.rows, [[u'guests', 50], [u'managers', 50], [u'users', 100]])
   845         self.assertEquals(rset.rows, [[u'guests', 50], [u'managers', 50], [u'users', 100]])
   846         self.assertEquals(rset.description, [('String', 'Int'), ('String', 'Int'), ('String', 'Int')])
   846         self.assertEquals(rset.description, [('String', 'Int'), ('String', 'Int'), ('String', 'Int')])
       
   847 
       
   848     def test_select_subquery_aggregat_2(self):
       
   849         expected = self.execute('Any X, 0, COUNT(T) GROUPBY X '
       
   850                                 'WHERE X is Workflow, T transition_of X').rows
       
   851         rset = self.execute('''
       
   852 Any P1,B,E WHERE P1 identity P2 WITH
       
   853   P1,B BEING (Any P,COUNT(T) GROUPBY P WHERE P is Workflow, T is Transition,
       
   854               T? transition_of P, T type "auto"),
       
   855   P2,E BEING (Any P,COUNT(T) GROUPBY P WHERE P is Workflow, T is Transition,
       
   856               T? transition_of P, T type "normal")''')
       
   857         self.assertEquals(sorted(rset.rows), sorted(expected))
   847 
   858 
   848     def test_select_subquery_const(self):
   859     def test_select_subquery_const(self):
   849         rset = self.execute('Any X WITH X BEING ((Any NULL) UNION (Any "toto"))')
   860         rset = self.execute('Any X WITH X BEING ((Any NULL) UNION (Any "toto"))')
   850         self.assertEquals(rset.rows, [[None], ['toto']])
   861         self.assertEquals(rset.rows, [[None], ['toto']])
   851         self.assertEquals(rset.description, [(None,), ('String',)])
   862         self.assertEquals(rset.description, [(None,), ('String',)])