server/test/unittest_msplanner.py
branchstable
changeset 6759 5d016d5bacca
parent 6758 28b11ecf319b
child 6781 5062d86d6ffe
equal deleted inserted replaced
6758:28b11ecf319b 6759:5d016d5bacca
    16 # You should have received a copy of the GNU Lesser General Public License along
    16 # You should have received a copy of the GNU Lesser General Public License along
    17 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
    17 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
    18 
    18 
    19 from logilab.common.decorators import clear_cache
    19 from logilab.common.decorators import clear_cache
    20 
    20 
       
    21 from yams.buildobjs import RelationDefinition
    21 from rql import BadRQLQuery
    22 from rql import BadRQLQuery
    22 
    23 
    23 from cubicweb.devtools import init_test_database
    24 from cubicweb.devtools import init_test_database
    24 from cubicweb.devtools.repotest import BasePlannerTC, test_plan
    25 from cubicweb.devtools.repotest import BasePlannerTC, test_plan
    25 
    26 
  1649                        [{u'A': 'Note', u'B': 'Note', 'DEP': 'Note', 'P': 'Note'}])],
  1650                        [{u'A': 'Note', u'B': 'Note', 'DEP': 'Note', 'P': 'Note'}])],
  1650                      None, None, [self.system],
  1651                      None, None, [self.system],
  1651                      {'A': 'table0.C0', 'B': 'table1.C0', 'DEP': 'table2.C0', 'P': 'table2.C1'},
  1652                      {'A': 'table0.C0', 'B': 'table1.C0', 'DEP': 'table2.C0', 'P': 'table2.C1'},
  1652                      [])])
  1653                      [])])
  1653 
  1654 
       
  1655     def test_crossed_relation_noeid_invariant(self):
       
  1656         # see comment in http://www.cubicweb.org/ticket/1382452
       
  1657         self.schema.add_relation_def(
       
  1658             RelationDefinition(subject='Note', name='multisource_crossed_rel', object='Affaire'))
       
  1659         self.repo.set_schema(self.schema)
       
  1660         try:
       
  1661             self._test('DISTINCT Any P,DEP WHERE P type "cubicweb-foo", P multisource_crossed_rel DEP',
       
  1662                        [('FetchStep',
       
  1663                          [('Any DEP WHERE DEP is Note', [{'DEP': 'Note'}])],
       
  1664                          [self.cards, self.system], None, {'DEP': 'table0.C0'}, []),
       
  1665                         ('FetchStep',
       
  1666                          [(u'Any P WHERE P type "cubicweb-foo", P is Note', [{'P': 'Note'}])],
       
  1667                          [self.cards, self.system], None, {'P': 'table1.C0'}, []),
       
  1668                         ('UnionStep', None, None,
       
  1669                          [('OneFetchStep',
       
  1670                            [('DISTINCT Any P,DEP WHERE P multisource_crossed_rel DEP, DEP is Note, P is Note',
       
  1671                              [{'DEP': 'Note', 'P': 'Note'}])],
       
  1672                            None, None, [self.cards], None, []),
       
  1673                           ('OneFetchStep',
       
  1674                            [('DISTINCT Any P,DEP WHERE P multisource_crossed_rel DEP, DEP is Note, P is Note',
       
  1675                              [{'DEP': 'Note', 'P': 'Note'}])],
       
  1676                            None, None, [self.system],
       
  1677                            {'DEP': 'table0.C0', 'P': 'table1.C0'},
       
  1678                            []),
       
  1679                           ('OneFetchStep',
       
  1680                            [('DISTINCT Any P,DEP WHERE P multisource_crossed_rel DEP, DEP is Affaire, P is Note',
       
  1681                              [{'DEP': 'Affaire', 'P': 'Note'}])],
       
  1682                            None, None, [self.system], {'P': 'table1.C0'},
       
  1683                            [])])
       
  1684                         ])
       
  1685         finally:
       
  1686             self.schema.del_relation_def('Note', 'multisource_crossed_rel', 'Affaire')
       
  1687             self.repo.set_schema(self.schema)
       
  1688 
  1654     # edition queries tests ###################################################
  1689     # edition queries tests ###################################################
  1655 
  1690 
  1656     def test_insert_simplified_var_1(self):
  1691     def test_insert_simplified_var_1(self):
  1657         repo._type_source_cache[999999] = ('Note', 'cards', 999999)
  1692         repo._type_source_cache[999999] = ('Note', 'cards', 999999)
  1658         repo._type_source_cache[999998] = ('State', 'system', None)
  1693         repo._type_source_cache[999998] = ('State', 'system', None)