server/test/unittest_msplanner.py
branchstable
changeset 7108 bcdf22734059
parent 6957 ffda12be2e9f
child 7188 b2c45b7396fb
equal deleted inserted replaced
7107:5ea4bf53eff2 7108:bcdf22734059
   428 
   428 
   429     def test_simple_system_ldap_ordered_limit_offset(self):
   429     def test_simple_system_ldap_ordered_limit_offset(self):
   430         """retrieve CWUser X from both sources and return concatenation of results
   430         """retrieve CWUser X from both sources and return concatenation of results
   431         """
   431         """
   432         self._test('CWUser X ORDERBY X LIMIT 10 OFFSET 10',
   432         self._test('CWUser X ORDERBY X LIMIT 10 OFFSET 10',
   433                    [('AggrStep', 'SELECT table0.C0 FROM table0 ORDER BY table0.C0 LIMIT 10 OFFSET 10', None, [
   433                    [('AggrStep', 'SELECT table0.C0 FROM table0\nORDER BY table0.C0\nLIMIT 10\nOFFSET 10', None, [
   434                        ('FetchStep', [('Any X WHERE X is CWUser', [{'X': 'CWUser'}])],
   434                        ('FetchStep', [('Any X WHERE X is CWUser', [{'X': 'CWUser'}])],
   435                         [self.ldap, self.system], {}, {'X': 'table0.C0'}, []),
   435                         [self.ldap, self.system], {}, {'X': 'table0.C0'}, []),
   436                        ]),
   436                        ]),
   437                    ])
   437                    ])
   438     def test_simple_system_ldap_aggregat(self):
   438     def test_simple_system_ldap_aggregat(self):
   513                      [self.system], {'X': 'table0.C0', 'X.login': 'table0.C1', 'L': 'table0.C1'}, [])
   513                      [self.system], {'X': 'table0.C0', 'X.login': 'table0.C1', 'L': 'table0.C1'}, [])
   514                     ])
   514                     ])
   515 
   515 
   516     def test_complex_ordered(self):
   516     def test_complex_ordered(self):
   517         self._test('Any L ORDERBY L WHERE X login L',
   517         self._test('Any L ORDERBY L WHERE X login L',
   518                    [('AggrStep', 'SELECT table0.C0 FROM table0 ORDER BY table0.C0', None,
   518                    [('AggrStep', 'SELECT table0.C0 FROM table0\nORDER BY table0.C0', None,
   519                      [('FetchStep', [('Any L WHERE X login L, X is CWUser',
   519                      [('FetchStep', [('Any L WHERE X login L, X is CWUser',
   520                                       [{'X': 'CWUser', 'L': 'String'}])],
   520                                       [{'X': 'CWUser', 'L': 'String'}])],
   521                        [self.ldap, self.system], {}, {'X.login': 'table0.C0', 'L': 'table0.C0'}, []),
   521                        [self.ldap, self.system], {}, {'X.login': 'table0.C0', 'L': 'table0.C0'}, []),
   522                       ])
   522                       ])
   523                     ])
   523                     ])
   524 
   524 
   525     def test_complex_ordered_limit_offset(self):
   525     def test_complex_ordered_limit_offset(self):
   526         self._test('Any L ORDERBY L LIMIT 10 OFFSET 10 WHERE X login L',
   526         self._test('Any L ORDERBY L LIMIT 10 OFFSET 10 WHERE X login L',
   527                    [('AggrStep', 'SELECT table0.C0 FROM table0 ORDER BY table0.C0 LIMIT 10 OFFSET 10', None,
   527                    [('AggrStep', 'SELECT table0.C0 FROM table0\nORDER BY table0.C0\nLIMIT 10\nOFFSET 10', None,
   528                      [('FetchStep', [('Any L WHERE X login L, X is CWUser',
   528                      [('FetchStep', [('Any L WHERE X login L, X is CWUser',
   529                                       [{'X': 'CWUser', 'L': 'String'}])],
   529                                       [{'X': 'CWUser', 'L': 'String'}])],
   530                        [self.ldap, self.system], {}, {'X.login': 'table0.C0', 'L': 'table0.C0'}, []),
   530                        [self.ldap, self.system], {}, {'X.login': 'table0.C0', 'L': 'table0.C0'}, []),
   531                       ])
   531                       ])
   532                     ])
   532                     ])
   608         1. retrieve CWUser X from system and ldap sources, Person X from system source only, store
   608         1. retrieve CWUser X from system and ldap sources, Person X from system source only, store
   609            each result in the same temp table
   609            each result in the same temp table
   610         2. return content of the table sorted
   610         2. return content of the table sorted
   611         """
   611         """
   612         self._test('Any X,F ORDERBY F WHERE X firstname F',
   612         self._test('Any X,F ORDERBY F WHERE X firstname F',
   613                    [('AggrStep', 'SELECT table0.C0, table0.C1 FROM table0 ORDER BY table0.C1', None,
   613                    [('AggrStep', 'SELECT table0.C0, table0.C1 FROM table0\nORDER BY table0.C1', None,
   614                      [('FetchStep', [('Any X,F WHERE X firstname F, X is CWUser',
   614                      [('FetchStep', [('Any X,F WHERE X firstname F, X is CWUser',
   615                                       [{'X': 'CWUser', 'F': 'String'}])],
   615                                       [{'X': 'CWUser', 'F': 'String'}])],
   616                        [self.ldap, self.system], {},
   616                        [self.ldap, self.system], {},
   617                        {'X': 'table0.C0', 'X.firstname': 'table0.C1', 'F': 'table0.C1'}, []),
   617                        {'X': 'table0.C0', 'X.firstname': 'table0.C1', 'F': 'table0.C1'}, []),
   618                       ('FetchStep', [('Any X,F WHERE X firstname F, X is Personne',
   618                       ('FetchStep', [('Any X,F WHERE X firstname F, X is Personne',
  1342 
  1342 
  1343     def test_has_text_orderby_rank(self):
  1343     def test_has_text_orderby_rank(self):
  1344         self._test('Any X ORDERBY FTIRANK(X) WHERE X has_text "bla", X firstname "bla"',
  1344         self._test('Any X ORDERBY FTIRANK(X) WHERE X has_text "bla", X firstname "bla"',
  1345                    [('FetchStep', [('Any X WHERE X firstname "bla", X is CWUser', [{'X': 'CWUser'}])],
  1345                    [('FetchStep', [('Any X WHERE X firstname "bla", X is CWUser', [{'X': 'CWUser'}])],
  1346                      [self.ldap, self.system], None, {'X': 'table0.C0'}, []),
  1346                      [self.ldap, self.system], None, {'X': 'table0.C0'}, []),
  1347                     ('AggrStep', 'SELECT table1.C1 FROM table1 ORDER BY table1.C0', None, [
  1347                     ('AggrStep', 'SELECT table1.C1 FROM table1\nORDER BY table1.C0', None, [
  1348                         ('FetchStep', [('Any FTIRANK(X),X WHERE X has_text "bla", X is CWUser',
  1348                         ('FetchStep', [('Any FTIRANK(X),X WHERE X has_text "bla", X is CWUser',
  1349                                         [{'X': 'CWUser'}])],
  1349                                         [{'X': 'CWUser'}])],
  1350                          [self.system], {'X': 'table0.C0'}, {'FTIRANK(X)': 'table1.C0', 'X': 'table1.C1'}, []),
  1350                          [self.system], {'X': 'table0.C0'}, {'FTIRANK(X)': 'table1.C0', 'X': 'table1.C1'}, []),
  1351                         ('FetchStep', [('Any FTIRANK(X),X WHERE X has_text "bla", X firstname "bla", X is Personne',
  1351                         ('FetchStep', [('Any FTIRANK(X),X WHERE X has_text "bla", X firstname "bla", X is Personne',
  1352                                         [{'X': 'Personne'}])],
  1352                                         [{'X': 'Personne'}])],
  1399                         ]),
  1399                         ]),
  1400                     ])
  1400                     ])
  1401 
  1401 
  1402     def test_sort_func(self):
  1402     def test_sort_func(self):
  1403         self._test('Note X ORDERBY DUMB_SORT(RF) WHERE X type RF',
  1403         self._test('Note X ORDERBY DUMB_SORT(RF) WHERE X type RF',
  1404                    [('AggrStep', 'SELECT table0.C0 FROM table0 ORDER BY DUMB_SORT(table0.C1)', None, [
  1404                    [('AggrStep', 'SELECT table0.C0 FROM table0\nORDER BY DUMB_SORT(table0.C1)', None, [
  1405                        ('FetchStep', [('Any X,RF WHERE X type RF, X is Note',
  1405                        ('FetchStep', [('Any X,RF WHERE X type RF, X is Note',
  1406                                        [{'X': 'Note', 'RF': 'String'}])],
  1406                                        [{'X': 'Note', 'RF': 'String'}])],
  1407                         [self.cards, self.system], {}, {'X': 'table0.C0', 'X.type': 'table0.C1', 'RF': 'table0.C1'}, []),
  1407                         [self.cards, self.system], {}, {'X': 'table0.C0', 'X.type': 'table0.C1', 'RF': 'table0.C1'}, []),
  1408                        ])
  1408                        ])
  1409                     ])
  1409                     ])
  1410 
  1410 
  1411     def test_ambigous_sort_func(self):
  1411     def test_ambigous_sort_func(self):
  1412         self._test('Any X ORDERBY DUMB_SORT(RF) WHERE X title RF, X is IN (Bookmark, Card, EmailThread)',
  1412         self._test('Any X ORDERBY DUMB_SORT(RF) WHERE X title RF, X is IN (Bookmark, Card, EmailThread)',
  1413                    [('AggrStep', 'SELECT table0.C0 FROM table0 ORDER BY DUMB_SORT(table0.C1)', None,
  1413                    [('AggrStep', 'SELECT table0.C0 FROM table0\nORDER BY DUMB_SORT(table0.C1)', None,
  1414                      [('FetchStep', [('Any X,RF WHERE X title RF, X is Card',
  1414                      [('FetchStep', [('Any X,RF WHERE X title RF, X is Card',
  1415                                       [{'X': 'Card', 'RF': 'String'}])],
  1415                                       [{'X': 'Card', 'RF': 'String'}])],
  1416                        [self.cards, self.system], {},
  1416                        [self.cards, self.system], {},
  1417                        {'X': 'table0.C0', 'X.title': 'table0.C1', 'RF': 'table0.C1'}, []),
  1417                        {'X': 'table0.C0', 'X.title': 'table0.C1', 'RF': 'table0.C1'}, []),
  1418                       ('FetchStep', [('Any X,RF WHERE X title RF, X is IN(Bookmark, EmailThread)',
  1418                       ('FetchStep', [('Any X,RF WHERE X title RF, X is IN(Bookmark, EmailThread)',
  1895         self.cards.support_relations['see_also'] = True
  1895         self.cards.support_relations['see_also'] = True
  1896         self.cards.cross_relations.add('see_also')
  1896         self.cards.cross_relations.add('see_also')
  1897         try:
  1897         try:
  1898             self._test('Any X,AA ORDERBY AA WHERE E eid %(x)s, E see_also X, X modification_date AA',
  1898             self._test('Any X,AA ORDERBY AA WHERE E eid %(x)s, E see_also X, X modification_date AA',
  1899                        [('AggrStep',
  1899                        [('AggrStep',
  1900                          'SELECT table0.C0, table0.C1 FROM table0 ORDER BY table0.C1',
  1900                          'SELECT table0.C0, table0.C1 FROM table0\nORDER BY table0.C1',
  1901                          None,
  1901                          None,
  1902                          [('FetchStep',
  1902                          [('FetchStep',
  1903                            [('Any X,AA WHERE 999999 see_also X, X modification_date AA, X is Note',
  1903                            [('Any X,AA WHERE 999999 see_also X, X modification_date AA, X is Note',
  1904                              [{'AA': 'Datetime', 'X': 'Note'}])], [self.cards, self.system], {},
  1904                              [{'AA': 'Datetime', 'X': 'Note'}])], [self.cards, self.system], {},
  1905                            {'AA': 'table0.C1', 'X': 'table0.C0',
  1905                            {'AA': 'table0.C1', 'X': 'table0.C0',
  2069         self.cards.support_relations['see_also'] = True
  2069         self.cards.support_relations['see_also'] = True
  2070         self.cards.cross_relations.add('see_also')
  2070         self.cards.cross_relations.add('see_also')
  2071         try:
  2071         try:
  2072             self._test('Any X,AA ORDERBY AA WHERE E eid %(x)s, E see_also X, X modification_date AA',
  2072             self._test('Any X,AA ORDERBY AA WHERE E eid %(x)s, E see_also X, X modification_date AA',
  2073                        [('AggrStep',
  2073                        [('AggrStep',
  2074                          'SELECT table0.C0, table0.C1 FROM table0 ORDER BY table0.C1',
  2074                          'SELECT table0.C0, table0.C1 FROM table0\nORDER BY table0.C1',
  2075                          None,
  2075                          None,
  2076                          [('FetchStep',
  2076                          [('FetchStep',
  2077                            [('Any X,AA WHERE 999999 see_also X, X modification_date AA, X is Note',
  2077                            [('Any X,AA WHERE 999999 see_also X, X modification_date AA, X is Note',
  2078                              [{'AA': 'Datetime', 'X': 'Note'}])], [self.cards, self.system], {},
  2078                              [{'AA': 'Datetime', 'X': 'Note'}])], [self.cards, self.system], {},
  2079                            {'AA': 'table0.C1', 'X': 'table0.C0',
  2079                            {'AA': 'table0.C1', 'X': 'table0.C0',
  2116                                     [{'X': 'Note', 'D': 'Datetime'}])],
  2116                                     [{'X': 'Note', 'D': 'Datetime'}])],
  2117                      [self.cards, self.system], None, {'X': 'table0.C0', 'X.modification_date': 'table0.C1', 'D': 'table0.C1'}, []),
  2117                      [self.cards, self.system], None, {'X': 'table0.C0', 'X.modification_date': 'table0.C1', 'D': 'table0.C1'}, []),
  2118                     ('FetchStep', [('Any X,D WHERE X modification_date D, X is CWUser',
  2118                     ('FetchStep', [('Any X,D WHERE X modification_date D, X is CWUser',
  2119                                     [{'X': 'CWUser', 'D': 'Datetime'}])],
  2119                                     [{'X': 'CWUser', 'D': 'Datetime'}])],
  2120                      [self.ldap, self.system], None, {'X': 'table1.C0', 'X.modification_date': 'table1.C1', 'D': 'table1.C1'}, []),
  2120                      [self.ldap, self.system], None, {'X': 'table1.C0', 'X.modification_date': 'table1.C1', 'D': 'table1.C1'}, []),
  2121                     ('AggrStep', 'SELECT table2.C0 FROM table2 ORDER BY table2.C1 DESC', None, [
  2121                     ('AggrStep', 'SELECT table2.C0 FROM table2\nORDER BY table2.C1 DESC', None, [
  2122                         ('FetchStep', [('Any X,D WHERE E eid %s, E wf_info_for X, X modification_date D, E is TrInfo, X is Affaire'%treid,
  2122                         ('FetchStep', [('Any X,D WHERE E eid %s, E wf_info_for X, X modification_date D, E is TrInfo, X is Affaire'%treid,
  2123                                         [{'X': 'Affaire', 'E': 'TrInfo', 'D': 'Datetime'}])],
  2123                                         [{'X': 'Affaire', 'E': 'TrInfo', 'D': 'Datetime'}])],
  2124                          [self.system],
  2124                          [self.system],
  2125                          {},
  2125                          {},
  2126                          {'X': 'table2.C0', 'X.modification_date': 'table2.C1', 'D': 'table2.C1', 'E.wf_info_for': 'table2.C0'}, []),
  2126                          {'X': 'table2.C0', 'X.modification_date': 'table2.C1', 'D': 'table2.C1', 'E.wf_info_for': 'table2.C0'}, []),
  2265         self._test('Any X ORDERBY Z DESC WHERE X modification_date Z, E eid %(x)s, E see_also X',
  2265         self._test('Any X ORDERBY Z DESC WHERE X modification_date Z, E eid %(x)s, E see_also X',
  2266                    [('FetchStep', [('Any X,Z WHERE X modification_date Z, X is Note',
  2266                    [('FetchStep', [('Any X,Z WHERE X modification_date Z, X is Note',
  2267                                     [{'X': 'Note', 'Z': 'Datetime'}])],
  2267                                     [{'X': 'Note', 'Z': 'Datetime'}])],
  2268                      [self.cards, self.system], None, {'X': 'table0.C0', 'X.modification_date': 'table0.C1', 'Z': 'table0.C1'},
  2268                      [self.cards, self.system], None, {'X': 'table0.C0', 'X.modification_date': 'table0.C1', 'Z': 'table0.C1'},
  2269                      []),
  2269                      []),
  2270                     ('AggrStep', 'SELECT table1.C0 FROM table1 ORDER BY table1.C1 DESC', None,
  2270                     ('AggrStep', 'SELECT table1.C0 FROM table1\nORDER BY table1.C1 DESC', None,
  2271                      [('FetchStep', [('Any X,Z WHERE X modification_date Z, 999999 see_also X, X is Bookmark',
  2271                      [('FetchStep', [('Any X,Z WHERE X modification_date Z, 999999 see_also X, X is Bookmark',
  2272                                       [{'X': 'Bookmark', 'Z': 'Datetime'}])],
  2272                                       [{'X': 'Bookmark', 'Z': 'Datetime'}])],
  2273                        [self.system], {},   {'X': 'table1.C0', 'X.modification_date': 'table1.C1',
  2273                        [self.system], {},   {'X': 'table1.C0', 'X.modification_date': 'table1.C1',
  2274                                              'Z': 'table1.C1'},
  2274                                              'Z': 'table1.C1'},
  2275                        []),
  2275                        []),