server/test/unittest_msplanner.py
changeset 1121 43fa67acd9d0
parent 1120 1c24cde4bf72
child 1122 9f37de24251f
--- a/server/test/unittest_msplanner.py	Fri Mar 20 12:51:39 2009 +0100
+++ b/server/test/unittest_msplanner.py	Fri Mar 20 14:01:11 2009 +0100
@@ -1818,7 +1818,8 @@
                       )],
                    {'x': 999999})
 
-    def test_nonregr13(self):
+    def test_nonregr13_1(self):
+        # identity wrapped into exists
         self._test('Any B,U,UL GROUPBY B,U,UL WHERE B created_by U?, B is File '
                    'WITH U,UL BEING (Any U,UL WHERE ME eid %(x)s, (EXISTS(U identity ME) '
                    'OR (EXISTS(U in_group G, G name IN("managers", "staff")))) '
@@ -1840,6 +1841,41 @@
                      {'U': 'table1.C0', 'UL': 'table1.C1'},
                      [])],
                    {'x': self.session.user.eid})
+        
+    def test_nonregr13_2(self):
+        # identity *not* wrapped into exists.
+        #
+        # XXX this test fail since in this case, in "U identity 5" U and 5 are
+        # from the same scope so constraints are applied (telling the U should
+        # come from the same source as user with eid 5).
+        #
+        # IMO this is normal, unless we introduce a special case for the
+        # identity relation. BUT I think it's better to leave it as is and to
+        # explain constraint propagation rules, and so why this should be
+        # wrapped in exists() is used in multi-source
+        self.skip('take a look at me if you wish')
+        self._test('Any B,U,UL GROUPBY B,U,UL WHERE B created_by U?, B is File '
+                   'WITH U,UL BEING (Any U,UL WHERE ME eid %(x)s, (U identity ME '
+                   'OR (EXISTS(U in_group G, G name IN("managers", "staff")))) '
+                   'OR (EXISTS(U in_group H, ME in_group H, NOT H name "users")), U login UL, U is EUser)',
+                   [('FetchStep', [('Any U,UL WHERE U login UL, U is EUser',
+                                    [{'U': 'EUser', 'UL': 'String'}])],
+                     [self.ldap, self.system], None,
+                     {'U': 'table0.C0', 'U.login': 'table0.C1', 'UL': 'table0.C1'},
+                     []),
+                    ('FetchStep', [('Any U,UL WHERE ((U identity 5) OR (EXISTS(U in_group G, G name IN("managers", "staff"), G is EGroup))) OR (EXISTS(U in_group H, 5 in_group H, NOT H name "users", H is EGroup)), U login UL, U is EUser',
+                                    [{'G': 'EGroup', 'H': 'EGroup', 'U': 'EUser', 'UL': 'String'}])],
+                     [self.system],
+                     {'U': 'table0.C0', 'U.login': 'table0.C1', 'UL': 'table0.C1'},
+                     {'U': 'table1.C0', 'U.login': 'table1.C1', 'UL': 'table1.C1'},
+                     []),
+                    ('OneFetchStep', [('Any B,U,UL GROUPBY B,U,UL WHERE B created_by U?, B is File',
+                                       [{'B': 'File', 'U': 'EUser', 'UL': 'String'}])],
+                     None, None, [self.system],
+                     {'U': 'table1.C0', 'UL': 'table1.C1'},
+                     [])],
+                   {'x': self.session.user.eid})
+
 
 class MSPlannerTwoSameExternalSourcesTC(BasePlannerTC):
     """test planner related feature on a 3-sources repository: