web/test/unittest_facet.py
changeset 8029 805d4e121b65
parent 8023 047e62cddee0
child 8598 95b3792a8947
equal deleted inserted replaced
8028:58e9bc8a1f2c 8029:805d4e121b65
   193         # selection is cluttered because rqlst has been prepared for facet (it
   193         # selection is cluttered because rqlst has been prepared for facet (it
   194         # is not in real life)
   194         # is not in real life)
   195         self.assertEqual(f.select.as_string(),
   195         self.assertEqual(f.select.as_string(),
   196                           "DISTINCT Any  WHERE X is CWUser, X login 'admin'")
   196                           "DISTINCT Any  WHERE X is CWUser, X login 'admin'")
   197 
   197 
       
   198     def test_bitfield(self):
       
   199         req, rset, rqlst, filtered_variable = self.prepare_rqlst(
       
   200             'CWAttribute X WHERE X ordernum XO',
       
   201             expected_baserql='Any X WHERE X ordernum XO, X is CWAttribute',
       
   202             expected_preparedrql='DISTINCT Any  WHERE X ordernum XO, X is CWAttribute')
       
   203         f = facet.BitFieldFacet(req, rset=rset,
       
   204                                 select=rqlst.children[0],
       
   205                                 filtered_variable=filtered_variable)
       
   206         f.choices = [('un', 1,), ('deux', 2,)]
       
   207         f.rtype = 'ordernum'
       
   208         self.assertEqual(f.vocabulary(),
       
   209                           [(u'deux', 2), (u'un', 1)])
       
   210         # ensure rqlst is left unmodified
       
   211         self.assertEqual(rqlst.as_string(), 'DISTINCT Any  WHERE X ordernum XO, X is CWAttribute')
       
   212         #rqlst = rset.syntax_tree()
       
   213         self.assertEqual(f.possible_values(),
       
   214                           ['2', '1'])
       
   215         # ensure rqlst is left unmodified
       
   216         self.assertEqual(rqlst.as_string(), 'DISTINCT Any  WHERE X ordernum XO, X is CWAttribute')
       
   217         req.form[f.__regid__] = '3'
       
   218         f.add_rql_restrictions()
       
   219         # selection is cluttered because rqlst has been prepared for facet (it
       
   220         # is not in real life)
       
   221         self.assertEqual(f.select.as_string(),
       
   222                           "DISTINCT Any  WHERE X ordernum XO, X is CWAttribute, X ordernum C HAVING 3 = (C & 3)")
       
   223 
   198     def test_rql_path_eid(self):
   224     def test_rql_path_eid(self):
   199         req, rset, rqlst, filtered_variable = self.prepare_rqlst()
   225         req, rset, rqlst, filtered_variable = self.prepare_rqlst()
   200         class RPF(facet.RQLPathFacet):
   226         class RPF(facet.RQLPathFacet):
   201             path = [('X created_by U'), ('U owned_by O'), ('O login OL')]
   227             path = [('X created_by U'), ('U owned_by O'), ('O login OL')]
   202             filter_variable = 'O'
   228             filter_variable = 'O'