server/test/unittest_msplanner.py
changeset 7995 9a9f35ef418c
parent 7886 b1c913a6d9f0
child 8022 1d9449663140
equal deleted inserted replaced
7994:af3fb709c061 7995:9a9f35ef418c
    62 class FakeDataFeedSource(FakeCardSource):
    62 class FakeDataFeedSource(FakeCardSource):
    63     copy_based_source = True
    63     copy_based_source = True
    64 
    64 
    65 X_ALL_SOLS = sorted([{'X': 'Affaire'}, {'X': 'BaseTransition'}, {'X': 'Basket'},
    65 X_ALL_SOLS = sorted([{'X': 'Affaire'}, {'X': 'BaseTransition'}, {'X': 'Basket'},
    66                      {'X': 'Bookmark'}, {'X': 'CWAttribute'}, {'X': 'CWCache'},
    66                      {'X': 'Bookmark'}, {'X': 'CWAttribute'}, {'X': 'CWCache'},
    67                      {'X': 'CWConstraint'}, {'X': 'CWConstraintType'}, {'X': 'CWEType'},
    67                      {'X': 'CWConstraint'}, {'X': 'CWConstraintType'}, {'X': 'CWDataImport'}, {'X': 'CWEType'},
    68                      {'X': 'CWGroup'}, {'X': 'CWPermission'}, {'X': 'CWProperty'},
    68                      {'X': 'CWGroup'}, {'X': 'CWPermission'}, {'X': 'CWProperty'},
    69                      {'X': 'CWRType'}, {'X': 'CWRelation'},
    69                      {'X': 'CWRType'}, {'X': 'CWRelation'},
    70                      {'X': 'CWSource'}, {'X': 'CWSourceHostConfig'}, {'X': 'CWSourceSchemaConfig'},
    70                      {'X': 'CWSource'}, {'X': 'CWSourceHostConfig'}, {'X': 'CWSourceSchemaConfig'},
    71                      {'X': 'CWUser'}, {'X': 'CWUniqueTogetherConstraint'},
    71                      {'X': 'CWUser'}, {'X': 'CWUniqueTogetherConstraint'},
    72                      {'X': 'Card'}, {'X': 'Comment'}, {'X': 'Division'},
    72                      {'X': 'Card'}, {'X': 'Comment'}, {'X': 'Division'},
   905         self.session = self.user_groups_session('guests')
   905         self.session = self.user_groups_session('guests')
   906         ueid = self.session.user.eid
   906         ueid = self.session.user.eid
   907         ALL_SOLS = X_ALL_SOLS[:]
   907         ALL_SOLS = X_ALL_SOLS[:]
   908         ALL_SOLS.remove({'X': 'CWSourceHostConfig'}) # not authorized
   908         ALL_SOLS.remove({'X': 'CWSourceHostConfig'}) # not authorized
   909         ALL_SOLS.remove({'X': 'CWSourceSchemaConfig'}) # not authorized
   909         ALL_SOLS.remove({'X': 'CWSourceSchemaConfig'}) # not authorized
       
   910         ALL_SOLS.remove({'X': 'CWDataImport'}) # not authorized
   910         self._test('Any MAX(X)',
   911         self._test('Any MAX(X)',
   911                    [('FetchStep', [('Any E WHERE E type "X", E is Note', [{'E': 'Note'}])],
   912                    [('FetchStep', [('Any E WHERE E type "X", E is Note', [{'E': 'Note'}])],
   912                      [self.cards, self.system],  None, {'E': 'table1.C0'}, []),
   913                      [self.cards, self.system],  None, {'E': 'table1.C0'}, []),
   913                     ('FetchStep', [('Any X WHERE X is CWUser', [{'X': 'CWUser'}])],
   914                     ('FetchStep', [('Any X WHERE X is CWUser', [{'X': 'CWUser'}])],
   914                      [self.ldap, self.system], None, {'X': 'table2.C0'}, []),
   915                      [self.ldap, self.system], None, {'X': 'table2.C0'}, []),
   955         # use a guest user
   956         # use a guest user
   956         self.session = self.user_groups_session('guests')
   957         self.session = self.user_groups_session('guests')
   957         ueid = self.session.user.eid
   958         ueid = self.session.user.eid
   958         X_ET_ALL_SOLS = []
   959         X_ET_ALL_SOLS = []
   959         for s in X_ALL_SOLS:
   960         for s in X_ALL_SOLS:
   960             if s in ({'X': 'CWSourceHostConfig'}, {'X': 'CWSourceSchemaConfig'}):
   961             if s in ({'X': 'CWSourceHostConfig'}, {'X': 'CWSourceSchemaConfig'}, {'X': 'CWDataImport'}):
   961                 continue # not authorized
   962                 continue # not authorized
   962             ets = {'ET': 'CWEType'}
   963             ets = {'ET': 'CWEType'}
   963             ets.update(s)
   964             ets.update(s)
   964             X_ET_ALL_SOLS.append(ets)
   965             X_ET_ALL_SOLS.append(ets)
   965         self._test('Any ET, COUNT(X) GROUPBY ET ORDERBY ET WHERE X is ET',
   966         self._test('Any ET, COUNT(X) GROUPBY ET ORDERBY ET WHERE X is ET',
   988                       ('UnionFetchStep',
   989                       ('UnionFetchStep',
   989                        [('FetchStep', [('Any ET,X WHERE X is ET, ET is CWEType, X is IN(BaseTransition, Bookmark, CWAttribute, CWCache, CWConstraint, CWConstraintType, CWEType, CWGroup, CWPermission, CWProperty, CWRType, CWRelation, CWSource, CWUniqueTogetherConstraint, Comment, Division, Email, EmailAddress, EmailPart, EmailThread, ExternalUri, File, Folder, Personne, RQLExpression, Societe, SubDivision, SubWorkflowExitPoint, Tag, TrInfo, Transition, Workflow, WorkflowTransition)',
   990                        [('FetchStep', [('Any ET,X WHERE X is ET, ET is CWEType, X is IN(BaseTransition, Bookmark, CWAttribute, CWCache, CWConstraint, CWConstraintType, CWEType, CWGroup, CWPermission, CWProperty, CWRType, CWRelation, CWSource, CWUniqueTogetherConstraint, Comment, Division, Email, EmailAddress, EmailPart, EmailThread, ExternalUri, File, Folder, Personne, RQLExpression, Societe, SubDivision, SubWorkflowExitPoint, Tag, TrInfo, Transition, Workflow, WorkflowTransition)',
   990                                         [{'X': 'BaseTransition', 'ET': 'CWEType'},
   991                                         [{'X': 'BaseTransition', 'ET': 'CWEType'},
   991                                          {'X': 'Bookmark', 'ET': 'CWEType'}, {'X': 'CWAttribute', 'ET': 'CWEType'},
   992                                          {'X': 'Bookmark', 'ET': 'CWEType'}, {'X': 'CWAttribute', 'ET': 'CWEType'},
   992                                          {'X': 'CWCache', 'ET': 'CWEType'}, {'X': 'CWConstraint', 'ET': 'CWEType'},
   993                                          {'X': 'CWCache', 'ET': 'CWEType'}, {'X': 'CWConstraint', 'ET': 'CWEType'},
   993                                          {'X': 'CWConstraintType', 'ET': 'CWEType'}, {'X': 'CWEType', 'ET': 'CWEType'},
   994                                          {'X': 'CWConstraintType', 'ET': 'CWEType'},
       
   995                                          {'X': 'CWEType', 'ET': 'CWEType'},
   994                                          {'X': 'CWGroup', 'ET': 'CWEType'}, {'X': 'CWPermission', 'ET': 'CWEType'},
   996                                          {'X': 'CWGroup', 'ET': 'CWEType'}, {'X': 'CWPermission', 'ET': 'CWEType'},
   995                                          {'X': 'CWProperty', 'ET': 'CWEType'}, {'X': 'CWRType', 'ET': 'CWEType'},
   997                                          {'X': 'CWProperty', 'ET': 'CWEType'}, {'X': 'CWRType', 'ET': 'CWEType'},
   996                                          {'X': 'CWSource', 'ET': 'CWEType'},
   998                                          {'X': 'CWSource', 'ET': 'CWEType'},
   997                                          {'X': 'CWRelation', 'ET': 'CWEType'},
   999                                          {'X': 'CWRelation', 'ET': 'CWEType'},
   998                                          {'X': 'CWUniqueTogetherConstraint', 'ET': 'CWEType'},
  1000                                          {'X': 'CWUniqueTogetherConstraint', 'ET': 'CWEType'},
  2659                                     [{'X': 'Note'}, {'X': 'State'}, {'X': 'Card'}])],
  2661                                     [{'X': 'Note'}, {'X': 'State'}, {'X': 'Card'}])],
  2660                      [self.cards, self.cards2, self.system],
  2662                      [self.cards, self.cards2, self.system],
  2661                      None, {'X': 'table0.C0'}, []),
  2663                      None, {'X': 'table0.C0'}, []),
  2662                     ('UnionStep', None, None,
  2664                     ('UnionStep', None, None,
  2663                      [('OneFetchStep',
  2665                      [('OneFetchStep',
  2664                        [(u'Any X WHERE X owned_by U, U login "anon", U is CWUser, X is IN(Affaire, BaseTransition, Basket, Bookmark, CWAttribute, CWCache, CWConstraint, CWConstraintType, CWEType, CWGroup, CWPermission, CWProperty, CWRType, CWRelation, CWSource, CWSourceHostConfig, CWSourceSchemaConfig, CWUniqueTogetherConstraint, CWUser, Division, Email, EmailAddress, EmailPart, EmailThread, ExternalUri, File, Folder, Personne, RQLExpression, Societe, SubDivision, SubWorkflowExitPoint, Tag, TrInfo, Transition, Workflow, WorkflowTransition)',
  2666                        [(u'Any X WHERE X owned_by U, U login "anon", U is CWUser, X is IN(Affaire, BaseTransition, Basket, Bookmark, CWAttribute, CWCache, CWConstraint, CWConstraintType, CWDataImport, CWEType, CWGroup, CWPermission, CWProperty, CWRType, CWRelation, CWSource, CWSourceHostConfig, CWSourceSchemaConfig, CWUniqueTogetherConstraint, CWUser, Division, Email, EmailAddress, EmailPart, EmailThread, ExternalUri, File, Folder, Personne, RQLExpression, Societe, SubDivision, SubWorkflowExitPoint, Tag, TrInfo, Transition, Workflow, WorkflowTransition)',
  2665                          [{'U': 'CWUser', 'X': 'Affaire'},
  2667                          [{'U': 'CWUser', 'X': 'Affaire'},
  2666                           {'U': 'CWUser', 'X': 'BaseTransition'},
  2668                           {'U': 'CWUser', 'X': 'BaseTransition'},
  2667                           {'U': 'CWUser', 'X': 'Basket'},
  2669                           {'U': 'CWUser', 'X': 'Basket'},
  2668                           {'U': 'CWUser', 'X': 'Bookmark'},
  2670                           {'U': 'CWUser', 'X': 'Bookmark'},
  2669                           {'U': 'CWUser', 'X': 'CWAttribute'},
  2671                           {'U': 'CWUser', 'X': 'CWAttribute'},
  2670                           {'U': 'CWUser', 'X': 'CWCache'},
  2672                           {'U': 'CWUser', 'X': 'CWCache'},
  2671                           {'U': 'CWUser', 'X': 'CWConstraint'},
  2673                           {'U': 'CWUser', 'X': 'CWConstraint'},
  2672                           {'U': 'CWUser', 'X': 'CWConstraintType'},
  2674                           {'U': 'CWUser', 'X': 'CWConstraintType'},
       
  2675                           {'U': 'CWUser', 'X': 'CWDataImport'},
  2673                           {'U': 'CWUser', 'X': 'CWEType'},
  2676                           {'U': 'CWUser', 'X': 'CWEType'},
  2674                           {'U': 'CWUser', 'X': 'CWGroup'},
  2677                           {'U': 'CWUser', 'X': 'CWGroup'},
  2675                           {'U': 'CWUser', 'X': 'CWPermission'},
  2678                           {'U': 'CWUser', 'X': 'CWPermission'},
  2676                           {'U': 'CWUser', 'X': 'CWProperty'},
  2679                           {'U': 'CWUser', 'X': 'CWProperty'},
  2677                           {'U': 'CWUser', 'X': 'CWRType'},
  2680                           {'U': 'CWUser', 'X': 'CWRType'},