server/test/unittest_msplanner.py
changeset 3293 69c0ba095536
parent 2968 0e3460341023
parent 3240 8604a15995d1
child 3589 a5432f99f2d9
equal deleted inserted replaced
3230:1d25e928c299 3293:69c0ba095536
   346 
   346 
   347 class MSPlannerTC(BaseMSPlannerTC):
   347 class MSPlannerTC(BaseMSPlannerTC):
   348 
   348 
   349     def setUp(self):
   349     def setUp(self):
   350         BaseMSPlannerTC.setUp(self)
   350         BaseMSPlannerTC.setUp(self)
   351         self.planner = MSPlanner(self.o.schema, self.o._rqlhelper)
   351         self.planner = MSPlanner(self.o.schema, self.repo.vreg.rqlhelper)
   352 
   352 
   353     _test = test_plan
   353     _test = test_plan
   354 
   354 
   355     def test_simple_system_only(self):
   355     def test_simple_system_only(self):
   356         """retrieve entities only supported by the system source
   356         """retrieve entities only supported by the system source
  1959         self._test('Any X WHERE X eid %(x)s, X owned_by U, U eid %(u)s',
  1959         self._test('Any X WHERE X eid %(x)s, X owned_by U, U eid %(u)s',
  1960                    [('OneFetchStep', [('Any 999998 WHERE 999998 owned_by 999999', [{}])],
  1960                    [('OneFetchStep', [('Any 999998 WHERE 999998 owned_by 999999', [{}])],
  1961                      None, None, [self.system], {}, [])],
  1961                      None, None, [self.system], {}, [])],
  1962                    {'x': 999998, 'u': 999999})
  1962                    {'x': 999998, 'u': 999999})
  1963 
  1963 
  1964     def test_nonregr_identity_no_source_access(self):
  1964     def test_nonregr_identity_no_source_access_1(self):
  1965         repo._type_source_cache[999999] = ('CWUser', 'ldap', 999998)
  1965         repo._type_source_cache[999999] = ('CWUser', 'ldap', 999998)
  1966         self._test('Any S WHERE S identity U, S eid %(s)s, U eid %(u)s',
  1966         self._test('Any S WHERE S identity U, S eid %(s)s, U eid %(u)s',
  1967                    [('OneFetchStep', [('Any 999999 WHERE 999999 identity 999999', [{}])],
  1967                    [('OneFetchStep', [('Any 999999 WHERE 999999 identity 999999', [{}])],
  1968                      None, None, [self.system], {}, [])],
  1968                      None, None, [self.system], {}, [])],
  1969                    {'s': 999999, 'u': 999999})
  1969                    {'s': 999999, 'u': 999999})
  1970 
  1970 
       
  1971     def test_nonregr_identity_no_source_access_2(self):
       
  1972         repo._type_source_cache[999999] = ('EmailAddress', 'system', 999999)
       
  1973         repo._type_source_cache[999998] = ('CWUser', 'ldap', 999998)
       
  1974         self._test('Any X WHERE O use_email X, ((EXISTS(O identity U)) OR (EXISTS(O in_group G, G name IN("managers", "staff")))) OR (EXISTS(O in_group G2, U in_group G2, NOT G2 name "users")), X eid %(x)s, U eid %(u)s',
       
  1975                    [('OneFetchStep', [('Any 999999 WHERE O use_email 999999, ((EXISTS(O identity 999998)) OR (EXISTS(O in_group G, G name IN("managers", "staff")))) OR (EXISTS(O in_group G2, 999998 in_group G2, NOT G2 name "users"))',
       
  1976                                        [{'G': 'CWGroup', 'G2': 'CWGroup', 'O': 'CWUser'}])],
       
  1977                      None, None, [self.system], {}, [])],
       
  1978                    {'x': 999999, 'u': 999998})
       
  1979 
       
  1980 
  1971 class MSPlannerTwoSameExternalSourcesTC(BasePlannerTC):
  1981 class MSPlannerTwoSameExternalSourcesTC(BasePlannerTC):
  1972     """test planner related feature on a 3-sources repository:
  1982     """test planner related feature on a 3-sources repository:
  1973 
  1983 
  1974     * 2 rql sources supporting Card
  1984     * 2 rql sources supporting Card
  1975     """
  1985     """
  1977 
  1987 
  1978     def setUp(self):
  1988     def setUp(self):
  1979         self.setup()
  1989         self.setup()
  1980         self.add_source(FakeCardSource, 'cards')
  1990         self.add_source(FakeCardSource, 'cards')
  1981         self.add_source(FakeCardSource, 'cards2')
  1991         self.add_source(FakeCardSource, 'cards2')
  1982         self.planner = MSPlanner(self.o.schema, self.o._rqlhelper)
  1992         self.planner = MSPlanner(self.o.schema, self.repo.vreg.rqlhelper)
  1983         assert repo.sources_by_uri['cards2'].support_relation('multisource_crossed_rel')
  1993         assert repo.sources_by_uri['cards2'].support_relation('multisource_crossed_rel')
  1984         assert 'multisource_crossed_rel' in repo.sources_by_uri['cards2'].cross_relations
  1994         assert 'multisource_crossed_rel' in repo.sources_by_uri['cards2'].cross_relations
  1985         assert repo.sources_by_uri['cards'].support_relation('multisource_crossed_rel')
  1995         assert repo.sources_by_uri['cards'].support_relation('multisource_crossed_rel')
  1986         assert 'multisource_crossed_rel' in repo.sources_by_uri['cards'].cross_relations
  1996         assert 'multisource_crossed_rel' in repo.sources_by_uri['cards'].cross_relations
  1987     _test = test_plan
  1997     _test = test_plan
  2130     repo = repo
  2140     repo = repo
  2131 
  2141 
  2132     def setUp(self):
  2142     def setUp(self):
  2133         self.setup()
  2143         self.setup()
  2134         self.add_source(FakeVCSSource, 'vcs')
  2144         self.add_source(FakeVCSSource, 'vcs')
  2135         self.planner = MSPlanner(self.o.schema, self.o._rqlhelper)
  2145         self.planner = MSPlanner(self.o.schema, self.repo.vreg.rqlhelper)
  2136     _test = test_plan
  2146     _test = test_plan
  2137 
  2147 
  2138     def test_multisource_inlined_rel_skipped(self):
  2148     def test_multisource_inlined_rel_skipped(self):
  2139         self._test('Any MAX(VC) '
  2149         self._test('Any MAX(VC) '
  2140                    'WHERE VC multisource_inlined_rel R2, R para %(branch)s, VC in_state S, S name "published", '
  2150                    'WHERE VC multisource_inlined_rel R2, R para %(branch)s, VC in_state S, S name "published", '