web/test/unittest_views_searchrestriction.py
changeset 7605 48abeac162fd
parent 6340 470d8e828fda
child 8544 3d049071957e
equal deleted inserted replaced
7604:1eb6090311ff 7605:48abeac162fd
     1 # copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     1 # copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
     2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
     3 #
     3 #
     4 # This file is part of CubicWeb.
     4 # This file is part of CubicWeb.
     5 #
     5 #
     6 # CubicWeb is free software: you can redistribute it and/or modify it under the
     6 # CubicWeb is free software: you can redistribute it and/or modify it under the
    13 # FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
    13 # FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
    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 """
       
    19 
    18 
    20 """
       
    21 from cubicweb.devtools.testlib import CubicWebTC
    19 from cubicweb.devtools.testlib import CubicWebTC
    22 from cubicweb.web.facet import insert_attr_select_relation, prepare_facets_rqlst
    20 from cubicweb.web import facet
    23 
    21 
    24 
    22 
    25 class InsertAttrRelationTC(CubicWebTC):
    23 class InsertAttrRelationTC(CubicWebTC):
    26 
    24 
    27     def parse(self, query):
    25     def parse(self, query):
    28         rqlst = self.vreg.parse(self.session, query)
    26         rqlst = self.vreg.parse(self.session, query)
    29         select = rqlst.children[0]
    27         select = rqlst.children[0]
    30         # XXX done in real life?
       
    31         select.remove_groups()
       
    32         return rqlst
    28         return rqlst
    33 
    29 
    34     def _generate(self, rqlst, rel, role, attr):
    30     def _generate(self, rqlst, rel, role, attr):
    35         mainvar = prepare_facets_rqlst(rqlst)[0]
    31         select = rqlst.children[0]
    36         insert_attr_select_relation(rqlst.children[0], mainvar, rel, role, attr)
    32         filtered_variable = facet.get_filtered_variable(select)
       
    33         facet.prepare_select(select, filtered_variable)
       
    34         facet.insert_attr_select_relation(select, filtered_variable,
       
    35                                           rel, role, attr)
    37         return rqlst.as_string()
    36         return rqlst.as_string()
    38 
    37 
    39     @property
    38     @property
    40     def select(self):
    39     def select(self):
    41         return self.parse('Any B,(NOW - CD),S,V,U,GROUP_CONCAT(TN),VN,P,CD,BMD '
    40         return self.parse('Any B,(NOW - CD),S,V,U,GROUP_CONCAT(TN),VN,P,CD,BMD '