web/test/unittest_facet.py
author Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
Thu, 07 Oct 2010 17:25:24 +0200
branchstable
changeset 6406 39663630ca3c
parent 6340 470d8e828fda
child 6380 63d5dbaef999
child 6433 95c40961df21
permissions -rw-r--r--
xml-escape <script> tags generated by HTMLHead
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6119
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     1
from cubicweb.devtools.testlib import CubicWebTC
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     2
from cubicweb.web import facet
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     3
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     4
class BaseFacetTC(CubicWebTC):
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     5
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     6
    def prepare_rqlst(self):
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     7
        req = self.request()
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     8
        rset = self.execute('CWUser X')
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     9
        rqlst = rset.syntax_tree().copy()
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    10
        req.vreg.rqlhelper.annotate(rqlst)
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    11
        mainvar, baserql = facet.prepare_facets_rqlst(rqlst, rset.args)
6340
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6338
diff changeset
    12
        self.assertEqual(mainvar.name, 'X')
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6338
diff changeset
    13
        self.assertEqual(baserql, 'Any X WHERE X is CWUser')
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6338
diff changeset
    14
        self.assertEqual(rqlst.as_string(), 'DISTINCT Any  WHERE X is CWUser')
6119
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    15
        return req, rset, rqlst, mainvar
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    16
6338
b520b86113e3 add test case demonstrating #1251910
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6119
diff changeset
    17
    def test_relation_simple(self):
6119
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    18
        req, rset, rqlst, mainvar = self.prepare_rqlst()
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    19
        f = facet.RelationFacet(req, rset=rset,
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    20
                                rqlst=rqlst.children[0],
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    21
                                filtered_variable=mainvar)
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    22
        f.rtype = 'in_group'
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    23
        f.role = 'subject'
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    24
        f.target_attr = 'name'
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    25
        guests, managers = [eid for eid, in self.execute('CWGroup G ORDERBY GN '
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    26
                                                         'WHERE G name GN, G name IN ("guests", "managers")')]
6340
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6338
diff changeset
    27
        self.assertEqual(f.vocabulary(),
6119
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    28
                          [(u'guests', guests), (u'managers', managers)])
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    29
        # ensure rqlst is left unmodified
6340
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6338
diff changeset
    30
        self.assertEqual(rqlst.as_string(), 'DISTINCT Any  WHERE X is CWUser')
6119
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    31
        #rqlst = rset.syntax_tree()
6340
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6338
diff changeset
    32
        self.assertEqual(f.possible_values(),
6119
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    33
                          [str(guests), str(managers)])
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    34
        # ensure rqlst is left unmodified
6340
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6338
diff changeset
    35
        self.assertEqual(rqlst.as_string(), 'DISTINCT Any  WHERE X is CWUser')
6119
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    36
        req.form[f.__regid__] = str(guests)
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    37
        f.add_rql_restrictions()
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    38
        # selection is cluttered because rqlst has been prepared for facet (it
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    39
        # is not in real life)
6340
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6338
diff changeset
    40
        self.assertEqual(f.rqlst.as_string(),
6119
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    41
                          'DISTINCT Any  WHERE X is CWUser, X in_group D, D eid %s' % guests)
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    42
6338
b520b86113e3 add test case demonstrating #1251910
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6119
diff changeset
    43
    def test_relation_optional_rel(self):
b520b86113e3 add test case demonstrating #1251910
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6119
diff changeset
    44
        req = self.request()
b520b86113e3 add test case demonstrating #1251910
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6119
diff changeset
    45
        rset = self.execute('Any X,GROUP_CONCAT(GN) GROUPBY X '
b520b86113e3 add test case demonstrating #1251910
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6119
diff changeset
    46
                            'WHERE X in_group G?, G name GN, NOT G name "users"')
b520b86113e3 add test case demonstrating #1251910
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6119
diff changeset
    47
        rqlst = rset.syntax_tree().copy()
b520b86113e3 add test case demonstrating #1251910
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6119
diff changeset
    48
        req.vreg.rqlhelper.annotate(rqlst)
b520b86113e3 add test case demonstrating #1251910
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6119
diff changeset
    49
        mainvar, baserql = facet.prepare_facets_rqlst(rqlst, rset.args)
b520b86113e3 add test case demonstrating #1251910
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6119
diff changeset
    50
b520b86113e3 add test case demonstrating #1251910
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6119
diff changeset
    51
        f = facet.RelationFacet(req, rset=rset,
b520b86113e3 add test case demonstrating #1251910
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6119
diff changeset
    52
                                rqlst=rqlst.children[0],
b520b86113e3 add test case demonstrating #1251910
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6119
diff changeset
    53
                                filtered_variable=mainvar)
b520b86113e3 add test case demonstrating #1251910
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6119
diff changeset
    54
        f.rtype = 'in_group'
b520b86113e3 add test case demonstrating #1251910
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6119
diff changeset
    55
        f.role = 'subject'
b520b86113e3 add test case demonstrating #1251910
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6119
diff changeset
    56
        f.target_attr = 'name'
b520b86113e3 add test case demonstrating #1251910
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6119
diff changeset
    57
        guests, managers = [eid for eid, in self.execute('CWGroup G ORDERBY GN '
b520b86113e3 add test case demonstrating #1251910
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6119
diff changeset
    58
                                                         'WHERE G name GN, G name IN ("guests", "managers")')]
6340
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6338
diff changeset
    59
        self.assertEqual(f.vocabulary(),
6338
b520b86113e3 add test case demonstrating #1251910
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6119
diff changeset
    60
                          [(u'guests', guests), (u'managers', managers)])
b520b86113e3 add test case demonstrating #1251910
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6119
diff changeset
    61
        # ensure rqlst is left unmodified
6340
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6338
diff changeset
    62
        self.assertEqual(rqlst.as_string(), 'DISTINCT Any  GROUPBY X WHERE X in_group G?, G name GN, NOT G name "users"')
6338
b520b86113e3 add test case demonstrating #1251910
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6119
diff changeset
    63
        #rqlst = rset.syntax_tree()
6340
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6338
diff changeset
    64
        self.assertEqual(sorted(f.possible_values()),
6338
b520b86113e3 add test case demonstrating #1251910
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6119
diff changeset
    65
                          [str(guests), str(managers)])
b520b86113e3 add test case demonstrating #1251910
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6119
diff changeset
    66
        # ensure rqlst is left unmodified
6340
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6338
diff changeset
    67
        self.assertEqual(rqlst.as_string(), 'DISTINCT Any  GROUPBY X WHERE X in_group G?, G name GN, NOT G name "users"')
6338
b520b86113e3 add test case demonstrating #1251910
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6119
diff changeset
    68
        req.form[f.__regid__] = str(guests)
b520b86113e3 add test case demonstrating #1251910
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6119
diff changeset
    69
        f.add_rql_restrictions()
b520b86113e3 add test case demonstrating #1251910
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6119
diff changeset
    70
        # selection is cluttered because rqlst has been prepared for facet (it
b520b86113e3 add test case demonstrating #1251910
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6119
diff changeset
    71
        # is not in real life)
6340
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6338
diff changeset
    72
        self.assertEqual(f.rqlst.as_string(),
6338
b520b86113e3 add test case demonstrating #1251910
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6119
diff changeset
    73
                          'DISTINCT Any  GROUPBY X WHERE X in_group G?, G name GN, NOT G name "users", X in_group D, D eid %s' % guests)
b520b86113e3 add test case demonstrating #1251910
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6119
diff changeset
    74
b520b86113e3 add test case demonstrating #1251910
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6119
diff changeset
    75
6119
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    76
    def test_relationattribute(self):
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    77
        req, rset, rqlst, mainvar = self.prepare_rqlst()
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    78
        f = facet.RelationAttributeFacet(req, rset=rset,
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    79
                                         rqlst=rqlst.children[0],
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    80
                                         filtered_variable=mainvar)
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    81
        f.rtype = 'in_group'
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    82
        f.role = 'subject'
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    83
        f.target_attr = 'name'
6340
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6338
diff changeset
    84
        self.assertEqual(f.vocabulary(),
6119
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    85
                          [(u'guests', u'guests'), (u'managers', u'managers')])
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    86
        # ensure rqlst is left unmodified
6340
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6338
diff changeset
    87
        self.assertEqual(rqlst.as_string(), 'DISTINCT Any  WHERE X is CWUser')
6119
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    88
        #rqlst = rset.syntax_tree()
6340
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6338
diff changeset
    89
        self.assertEqual(f.possible_values(),
6119
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    90
                          ['guests', 'managers'])
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    91
        # ensure rqlst is left unmodified
6340
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6338
diff changeset
    92
        self.assertEqual(rqlst.as_string(), 'DISTINCT Any  WHERE X is CWUser')
6119
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    93
        req.form[f.__regid__] = 'guests'
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    94
        f.add_rql_restrictions()
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    95
        # selection is cluttered because rqlst has been prepared for facet (it
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    96
        # is not in real life)
6340
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6338
diff changeset
    97
        self.assertEqual(f.rqlst.as_string(),
6119
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    98
                          "DISTINCT Any  WHERE X is CWUser, X in_group E, E name 'guests'")
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    99
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   100
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   101
    def test_attribute(self):
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   102
        req, rset, rqlst, mainvar = self.prepare_rqlst()
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   103
        f = facet.AttributeFacet(req, rset=rset,
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   104
                                 rqlst=rqlst.children[0],
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   105
                                 filtered_variable=mainvar)
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   106
        f.rtype = 'login'
6340
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6338
diff changeset
   107
        self.assertEqual(f.vocabulary(),
6119
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   108
                          [(u'admin', u'admin'), (u'anon', u'anon')])
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   109
        # ensure rqlst is left unmodified
6340
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6338
diff changeset
   110
        self.assertEqual(rqlst.as_string(), 'DISTINCT Any  WHERE X is CWUser')
6119
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   111
        #rqlst = rset.syntax_tree()
6340
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6338
diff changeset
   112
        self.assertEqual(f.possible_values(),
6119
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   113
                          ['admin', 'anon'])
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   114
        # ensure rqlst is left unmodified
6340
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6338
diff changeset
   115
        self.assertEqual(rqlst.as_string(), 'DISTINCT Any  WHERE X is CWUser')
6119
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   116
        req.form[f.__regid__] = 'admin'
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   117
        f.add_rql_restrictions()
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   118
        # selection is cluttered because rqlst has been prepared for facet (it
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   119
        # is not in real life)
6340
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6338
diff changeset
   120
        self.assertEqual(f.rqlst.as_string(),
6119
b217635d3b28 new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   121
                          "DISTINCT Any  WHERE X is CWUser, X login 'admin'")