cubicweb/test/unittest_rqlrewrite.py
changeset 12567 26744ad37953
parent 12496 ad995a9905f9
child 12882 3ddd03309315
equal deleted inserted replaced
12566:6b3523f81f42 12567:26744ad37953
    14 # details.
    14 # details.
    15 #
    15 #
    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 six import string_types
       
    20 
       
    21 from logilab.common.testlib import mock_object
    19 from logilab.common.testlib import mock_object
    22 from logilab.common.decorators import monkeypatch
    20 from logilab.common.decorators import monkeypatch
    23 from yams import BadSchemaDefinition
    21 from yams import BadSchemaDefinition
    24 from yams.buildobjs import RelationDefinition
    22 from yams.buildobjs import RelationDefinition
    25 from rql import parse, nodes, RQLHelper
    23 from rql import parse, nodes, RQLHelper
    86             if snippet in snippet_varmap and not (
    84             if snippet in snippet_varmap and not (
    87                     set(varmap.values()) & set(snippet_varmap[snippet].values())):
    85                     set(varmap.values()) & set(snippet_varmap[snippet].values())):
    88                 snippet_varmap[snippet].update(varmap)
    86                 snippet_varmap[snippet].update(varmap)
    89                 continue
    87                 continue
    90             snippet_varmap[snippet] = varmap
    88             snippet_varmap[snippet] = varmap
    91             if isinstance(snippet, string_types):
    89             if isinstance(snippet, str):
    92                 snippet = mock_object(snippet_rqlst=parse(u'Any X WHERE ' + snippet).children[0],
    90                 snippet = mock_object(snippet_rqlst=parse(u'Any X WHERE ' + snippet).children[0],
    93                                       expression=u'Any X WHERE ' + snippet)
    91                                       expression=u'Any X WHERE ' + snippet)
    94             rqlexprs.append(snippet)
    92             rqlexprs.append(snippet)
    95         if rqlexprs:
    93         if rqlexprs:
    96             snippets.append((varmap, rqlexprs))
    94             snippets.append((varmap, rqlexprs))