author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Wed, 28 Sep 2011 09:27:42 +0200 | |
branch | stable |
changeset 7879 | 9aae456abab5 |
parent 7874 | be04706eacc9 |
child 8023 | 047e62cddee0 |
permissions | -rw-r--r-- |
7615
e5ad51352eb3
[facet] fix argument inversion in date range facet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7612
diff
changeset
|
1 |
from logilab.common.date import datetime2ticks |
6119
b217635d3b28
new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
2 |
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
|
3 |
from cubicweb.web import facet |
b217635d3b28
new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
4 |
|
b217635d3b28
new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
5 |
class BaseFacetTC(CubicWebTC): |
b217635d3b28
new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
6 |
|
7624
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
7 |
def prepare_rqlst(self, rql='CWUser X', baserql='Any X WHERE X is CWUser', |
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
8 |
preparedrql='DISTINCT Any WHERE X is CWUser', |
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
9 |
mainvar='X'): |
6119
b217635d3b28
new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
10 |
req = self.request() |
7624
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
11 |
rset = self.execute(rql) |
6119
b217635d3b28
new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
12 |
rqlst = rset.syntax_tree().copy() |
7624
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
13 |
filtered_variable, baserql = facet.init_facets(rset, rqlst.children[0], |
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
14 |
mainvar=mainvar) |
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
15 |
self.assertEqual(filtered_variable.name, mainvar) |
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
16 |
self.assertEqual(baserql, baserql) |
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
17 |
self.assertEqual(rqlst.as_string(), preparedrql) |
7605
48abeac162fd
[facets] refactor / cleanup facet api: more consistent variable naming and easier to reuse function. Closes #1796804
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7601
diff
changeset
|
18 |
return req, rset, rqlst, filtered_variable |
6119
b217635d3b28
new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
19 |
|
6380
63d5dbaef999
[facets] support for `no_relation` on RelationFacet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
20 |
def _in_group_facet(self, cls=facet.RelationFacet, no_relation=False): |
7605
48abeac162fd
[facets] refactor / cleanup facet api: more consistent variable naming and easier to reuse function. Closes #1796804
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7601
diff
changeset
|
21 |
req, rset, rqlst, filtered_variable = self.prepare_rqlst() |
6380
63d5dbaef999
[facets] support for `no_relation` on RelationFacet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
22 |
cls.no_relation = no_relation |
7605
48abeac162fd
[facets] refactor / cleanup facet api: more consistent variable naming and easier to reuse function. Closes #1796804
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7601
diff
changeset
|
23 |
f = cls(req, rset=rset, select=rqlst.children[0], |
48abeac162fd
[facets] refactor / cleanup facet api: more consistent variable naming and easier to reuse function. Closes #1796804
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7601
diff
changeset
|
24 |
filtered_variable=filtered_variable) |
6380
63d5dbaef999
[facets] support for `no_relation` on RelationFacet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
25 |
f.__regid__ = 'in_group' |
6119
b217635d3b28
new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
26 |
f.rtype = 'in_group' |
b217635d3b28
new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
27 |
f.role = 'subject' |
b217635d3b28
new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
28 |
f.target_attr = 'name' |
b217635d3b28
new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
29 |
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
|
30 |
'WHERE G name GN, G name IN ("guests", "managers")')] |
6380
63d5dbaef999
[facets] support for `no_relation` on RelationFacet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
31 |
groups = [eid for eid, in self.execute('CWGroup G ORDERBY GN ' |
63d5dbaef999
[facets] support for `no_relation` on RelationFacet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
32 |
'WHERE G name GN, G name IN ("guests", "managers")')] |
63d5dbaef999
[facets] support for `no_relation` on RelationFacet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
33 |
return f, groups |
63d5dbaef999
[facets] support for `no_relation` on RelationFacet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
34 |
|
63d5dbaef999
[facets] support for `no_relation` on RelationFacet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
35 |
def test_relation_simple(self): |
63d5dbaef999
[facets] support for `no_relation` on RelationFacet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
36 |
f, (guests, managers) = self._in_group_facet() |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6338
diff
changeset
|
37 |
self.assertEqual(f.vocabulary(), |
6380
63d5dbaef999
[facets] support for `no_relation` on RelationFacet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
38 |
[(u'guests', guests), (u'managers', managers)]) |
6119
b217635d3b28
new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
39 |
# ensure rqlst is left unmodified |
7605
48abeac162fd
[facets] refactor / cleanup facet api: more consistent variable naming and easier to reuse function. Closes #1796804
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7601
diff
changeset
|
40 |
self.assertEqual(f.select.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
|
41 |
#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
|
42 |
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
|
43 |
[str(guests), str(managers)]) |
b217635d3b28
new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
44 |
# ensure rqlst is left unmodified |
7605
48abeac162fd
[facets] refactor / cleanup facet api: more consistent variable naming and easier to reuse function. Closes #1796804
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7601
diff
changeset
|
45 |
self.assertEqual(f.select.as_string(), 'DISTINCT Any WHERE X is CWUser') |
6380
63d5dbaef999
[facets] support for `no_relation` on RelationFacet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
46 |
f._cw.form[f.__regid__] = str(guests) |
6119
b217635d3b28
new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
47 |
f.add_rql_restrictions() |
b217635d3b28
new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
48 |
# 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
|
49 |
# is not in real life) |
7605
48abeac162fd
[facets] refactor / cleanup facet api: more consistent variable naming and easier to reuse function. Closes #1796804
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7601
diff
changeset
|
50 |
self.assertEqual(f.select.as_string(), |
7618
5395007c415c
[facet] closes #1806931: new facet type, based on arbitrary rql path
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7615
diff
changeset
|
51 |
'DISTINCT Any WHERE X is CWUser, X in_group D, D eid %s' % guests) |
6119
b217635d3b28
new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
52 |
|
7768
bd44f506ca86
closes #1914824: fix retrieval of _andor input, test and fix generated rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7629
diff
changeset
|
53 |
def test_relation_multiple_and(self): |
bd44f506ca86
closes #1914824: fix retrieval of _andor input, test and fix generated rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7629
diff
changeset
|
54 |
f, (guests, managers) = self._in_group_facet() |
bd44f506ca86
closes #1914824: fix retrieval of _andor input, test and fix generated rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7629
diff
changeset
|
55 |
f._cw.form[f.__regid__] = [str(guests), str(managers)] |
bd44f506ca86
closes #1914824: fix retrieval of _andor input, test and fix generated rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7629
diff
changeset
|
56 |
f._cw.form[f.__regid__ + '_andor'] = 'AND' |
bd44f506ca86
closes #1914824: fix retrieval of _andor input, test and fix generated rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7629
diff
changeset
|
57 |
f.add_rql_restrictions() |
bd44f506ca86
closes #1914824: fix retrieval of _andor input, test and fix generated rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7629
diff
changeset
|
58 |
self.assertEqual(f.select.as_string(), |
bd44f506ca86
closes #1914824: fix retrieval of _andor input, test and fix generated rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7629
diff
changeset
|
59 |
'DISTINCT Any WHERE X is CWUser, X in_group A, B eid %s, X in_group B, A eid %s' % (guests, managers)) |
bd44f506ca86
closes #1914824: fix retrieval of _andor input, test and fix generated rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7629
diff
changeset
|
60 |
|
bd44f506ca86
closes #1914824: fix retrieval of _andor input, test and fix generated rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7629
diff
changeset
|
61 |
def test_relation_multiple_or(self): |
bd44f506ca86
closes #1914824: fix retrieval of _andor input, test and fix generated rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7629
diff
changeset
|
62 |
f, (guests, managers) = self._in_group_facet() |
bd44f506ca86
closes #1914824: fix retrieval of _andor input, test and fix generated rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7629
diff
changeset
|
63 |
f._cw.form[f.__regid__] = [str(guests), str(managers)] |
bd44f506ca86
closes #1914824: fix retrieval of _andor input, test and fix generated rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7629
diff
changeset
|
64 |
f._cw.form[f.__regid__ + '_andor'] = 'OR' |
bd44f506ca86
closes #1914824: fix retrieval of _andor input, test and fix generated rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7629
diff
changeset
|
65 |
f.add_rql_restrictions() |
bd44f506ca86
closes #1914824: fix retrieval of _andor input, test and fix generated rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7629
diff
changeset
|
66 |
self.assertEqual(f.select.as_string(), |
bd44f506ca86
closes #1914824: fix retrieval of _andor input, test and fix generated rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7629
diff
changeset
|
67 |
'DISTINCT Any WHERE X is CWUser, X in_group A, A eid IN(%s, %s)' % (guests, managers)) |
bd44f506ca86
closes #1914824: fix retrieval of _andor input, test and fix generated rql
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7629
diff
changeset
|
68 |
|
6338
b520b86113e3
add test case demonstrating #1251910
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6119
diff
changeset
|
69 |
def test_relation_optional_rel(self): |
b520b86113e3
add test case demonstrating #1251910
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6119
diff
changeset
|
70 |
req = self.request() |
b520b86113e3
add test case demonstrating #1251910
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6119
diff
changeset
|
71 |
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
|
72 |
'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
|
73 |
rqlst = rset.syntax_tree().copy() |
7605
48abeac162fd
[facets] refactor / cleanup facet api: more consistent variable naming and easier to reuse function. Closes #1796804
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7601
diff
changeset
|
74 |
select = rqlst.children[0] |
48abeac162fd
[facets] refactor / cleanup facet api: more consistent variable naming and easier to reuse function. Closes #1796804
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7601
diff
changeset
|
75 |
filtered_variable, baserql = facet.init_facets(rset, select) |
6338
b520b86113e3
add test case demonstrating #1251910
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6119
diff
changeset
|
76 |
|
b520b86113e3
add test case demonstrating #1251910
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6119
diff
changeset
|
77 |
f = facet.RelationFacet(req, rset=rset, |
7605
48abeac162fd
[facets] refactor / cleanup facet api: more consistent variable naming and easier to reuse function. Closes #1796804
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7601
diff
changeset
|
78 |
select=select, |
48abeac162fd
[facets] refactor / cleanup facet api: more consistent variable naming and easier to reuse function. Closes #1796804
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7601
diff
changeset
|
79 |
filtered_variable=filtered_variable) |
6338
b520b86113e3
add test case demonstrating #1251910
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6119
diff
changeset
|
80 |
f.rtype = 'in_group' |
b520b86113e3
add test case demonstrating #1251910
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6119
diff
changeset
|
81 |
f.role = 'subject' |
b520b86113e3
add test case demonstrating #1251910
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6119
diff
changeset
|
82 |
f.target_attr = 'name' |
b520b86113e3
add test case demonstrating #1251910
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6119
diff
changeset
|
83 |
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
|
84 |
'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
|
85 |
self.assertEqual(f.vocabulary(), |
6338
b520b86113e3
add test case demonstrating #1251910
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6119
diff
changeset
|
86 |
[(u'guests', guests), (u'managers', managers)]) |
b520b86113e3
add test case demonstrating #1251910
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6119
diff
changeset
|
87 |
# ensure rqlst is left unmodified |
7601
9030e8a4481e
[facets] should remove groupby from base rqlst. Closes #1796196
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6435
diff
changeset
|
88 |
self.assertEqual(rqlst.as_string(), 'DISTINCT Any 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
|
89 |
#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
|
90 |
self.assertEqual(sorted(f.possible_values()), |
6338
b520b86113e3
add test case demonstrating #1251910
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6119
diff
changeset
|
91 |
[str(guests), str(managers)]) |
b520b86113e3
add test case demonstrating #1251910
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6119
diff
changeset
|
92 |
# ensure rqlst is left unmodified |
7601
9030e8a4481e
[facets] should remove groupby from base rqlst. Closes #1796196
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6435
diff
changeset
|
93 |
self.assertEqual(rqlst.as_string(), 'DISTINCT Any 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
|
94 |
req.form[f.__regid__] = str(guests) |
b520b86113e3
add test case demonstrating #1251910
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6119
diff
changeset
|
95 |
f.add_rql_restrictions() |
b520b86113e3
add test case demonstrating #1251910
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6119
diff
changeset
|
96 |
# 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
|
97 |
# is not in real life) |
7601
9030e8a4481e
[facets] should remove groupby from base rqlst. Closes #1796196
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6435
diff
changeset
|
98 |
self.assertEqual(f.select.as_string(), |
9030e8a4481e
[facets] should remove groupby from base rqlst. Closes #1796196
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6435
diff
changeset
|
99 |
'DISTINCT Any WHERE X in_group G?, G name GN, NOT G name "users", X in_group D, D eid %s' % guests) |
6338
b520b86113e3
add test case demonstrating #1251910
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6119
diff
changeset
|
100 |
|
6380
63d5dbaef999
[facets] support for `no_relation` on RelationFacet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
101 |
def test_relation_no_relation_1(self): |
63d5dbaef999
[facets] support for `no_relation` on RelationFacet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
102 |
f, (guests, managers) = self._in_group_facet(no_relation=True) |
63d5dbaef999
[facets] support for `no_relation` on RelationFacet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
103 |
self.assertEqual(f.vocabulary(), |
63d5dbaef999
[facets] support for `no_relation` on RelationFacet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
104 |
[(u'guests', guests), (u'managers', managers)]) |
63d5dbaef999
[facets] support for `no_relation` on RelationFacet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
105 |
self.assertEqual(f.possible_values(), |
63d5dbaef999
[facets] support for `no_relation` on RelationFacet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
106 |
[str(guests), str(managers)]) |
63d5dbaef999
[facets] support for `no_relation` on RelationFacet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
107 |
f._cw.create_entity('CWUser', login=u'hop', upassword='toto') |
63d5dbaef999
[facets] support for `no_relation` on RelationFacet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
108 |
self.assertEqual(f.vocabulary(), |
6417
d2361abe8505
[test] fixes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6380
diff
changeset
|
109 |
[(u'<no relation>', ''), (u'guests', guests), (u'managers', managers)]) |
6380
63d5dbaef999
[facets] support for `no_relation` on RelationFacet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
110 |
self.assertEqual(f.possible_values(), |
6417
d2361abe8505
[test] fixes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6380
diff
changeset
|
111 |
[str(guests), str(managers), '']) |
6380
63d5dbaef999
[facets] support for `no_relation` on RelationFacet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
112 |
f._cw.form[f.__regid__] = '' |
63d5dbaef999
[facets] support for `no_relation` on RelationFacet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
113 |
f.add_rql_restrictions() |
7605
48abeac162fd
[facets] refactor / cleanup facet api: more consistent variable naming and easier to reuse function. Closes #1796804
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7601
diff
changeset
|
114 |
self.assertEqual(f.select.as_string(), |
6380
63d5dbaef999
[facets] support for `no_relation` on RelationFacet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
115 |
'DISTINCT Any WHERE X is CWUser, NOT X in_group G') |
63d5dbaef999
[facets] support for `no_relation` on RelationFacet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
116 |
|
63d5dbaef999
[facets] support for `no_relation` on RelationFacet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
117 |
def test_relation_no_relation_2(self): |
63d5dbaef999
[facets] support for `no_relation` on RelationFacet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
118 |
f, (guests, managers) = self._in_group_facet(no_relation=True) |
63d5dbaef999
[facets] support for `no_relation` on RelationFacet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
119 |
f._cw.form[f.__regid__] = ['', guests] |
7605
48abeac162fd
[facets] refactor / cleanup facet api: more consistent variable naming and easier to reuse function. Closes #1796804
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7601
diff
changeset
|
120 |
f.select.save_state() |
6380
63d5dbaef999
[facets] support for `no_relation` on RelationFacet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
121 |
f.add_rql_restrictions() |
7605
48abeac162fd
[facets] refactor / cleanup facet api: more consistent variable naming and easier to reuse function. Closes #1796804
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7601
diff
changeset
|
122 |
self.assertEqual(f.select.as_string(), |
6380
63d5dbaef999
[facets] support for `no_relation` on RelationFacet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
123 |
'DISTINCT Any WHERE X is CWUser, (NOT X in_group B) OR (X in_group A, A eid %s)' % guests) |
7605
48abeac162fd
[facets] refactor / cleanup facet api: more consistent variable naming and easier to reuse function. Closes #1796804
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7601
diff
changeset
|
124 |
f.select.recover() |
48abeac162fd
[facets] refactor / cleanup facet api: more consistent variable naming and easier to reuse function. Closes #1796804
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7601
diff
changeset
|
125 |
self.assertEqual(f.select.as_string(), |
6380
63d5dbaef999
[facets] support for `no_relation` on RelationFacet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
126 |
'DISTINCT Any WHERE X is CWUser') |
63d5dbaef999
[facets] support for `no_relation` on RelationFacet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
127 |
|
63d5dbaef999
[facets] support for `no_relation` on RelationFacet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
128 |
|
6338
b520b86113e3
add test case demonstrating #1251910
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6119
diff
changeset
|
129 |
|
6119
b217635d3b28
new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
130 |
def test_relationattribute(self): |
6380
63d5dbaef999
[facets] support for `no_relation` on RelationFacet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
131 |
f, (guests, managers) = self._in_group_facet(cls=facet.RelationAttributeFacet) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6338
diff
changeset
|
132 |
self.assertEqual(f.vocabulary(), |
6119
b217635d3b28
new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
133 |
[(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
|
134 |
# ensure rqlst is left unmodified |
7605
48abeac162fd
[facets] refactor / cleanup facet api: more consistent variable naming and easier to reuse function. Closes #1796804
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7601
diff
changeset
|
135 |
self.assertEqual(f.select.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
|
136 |
#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
|
137 |
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
|
138 |
['guests', 'managers']) |
b217635d3b28
new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
139 |
# ensure rqlst is left unmodified |
7605
48abeac162fd
[facets] refactor / cleanup facet api: more consistent variable naming and easier to reuse function. Closes #1796804
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7601
diff
changeset
|
140 |
self.assertEqual(f.select.as_string(), 'DISTINCT Any WHERE X is CWUser') |
6380
63d5dbaef999
[facets] support for `no_relation` on RelationFacet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
141 |
f._cw.form[f.__regid__] = 'guests' |
6119
b217635d3b28
new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
142 |
f.add_rql_restrictions() |
b217635d3b28
new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
143 |
# 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
|
144 |
# is not in real life) |
7605
48abeac162fd
[facets] refactor / cleanup facet api: more consistent variable naming and easier to reuse function. Closes #1796804
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7601
diff
changeset
|
145 |
self.assertEqual(f.select.as_string(), |
6119
b217635d3b28
new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
146 |
"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
|
147 |
|
7615
e5ad51352eb3
[facet] fix argument inversion in date range facet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7612
diff
changeset
|
148 |
def test_daterange(self): |
e5ad51352eb3
[facet] fix argument inversion in date range facet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7612
diff
changeset
|
149 |
req, rset, rqlst, filtered_variable = self.prepare_rqlst() |
e5ad51352eb3
[facet] fix argument inversion in date range facet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7612
diff
changeset
|
150 |
f = facet.DateRangeFacet(req, rset=rset, |
e5ad51352eb3
[facet] fix argument inversion in date range facet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7612
diff
changeset
|
151 |
select=rqlst.children[0], |
e5ad51352eb3
[facet] fix argument inversion in date range facet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7612
diff
changeset
|
152 |
filtered_variable=filtered_variable) |
e5ad51352eb3
[facet] fix argument inversion in date range facet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7612
diff
changeset
|
153 |
f.rtype = 'creation_date' |
7629
58f11f7dad68
[range facet] closes #1806937: simply retrieve min/max values when computing vocabulary/possible_values, this is enough
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7624
diff
changeset
|
154 |
mind, maxd = self.execute('Any MIN(CD), MAX(CD) WHERE X is CWUser, X creation_date CD')[0] |
7615
e5ad51352eb3
[facet] fix argument inversion in date range facet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7612
diff
changeset
|
155 |
self.assertEqual(f.vocabulary(), |
7629
58f11f7dad68
[range facet] closes #1806937: simply retrieve min/max values when computing vocabulary/possible_values, this is enough
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7624
diff
changeset
|
156 |
[(str(mind), mind), |
58f11f7dad68
[range facet] closes #1806937: simply retrieve min/max values when computing vocabulary/possible_values, this is enough
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7624
diff
changeset
|
157 |
(str(maxd), maxd)]) |
7615
e5ad51352eb3
[facet] fix argument inversion in date range facet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7612
diff
changeset
|
158 |
# ensure rqlst is left unmodified |
e5ad51352eb3
[facet] fix argument inversion in date range facet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7612
diff
changeset
|
159 |
self.assertEqual(rqlst.as_string(), 'DISTINCT Any WHERE X is CWUser') |
e5ad51352eb3
[facet] fix argument inversion in date range facet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7612
diff
changeset
|
160 |
#rqlst = rset.syntax_tree() |
e5ad51352eb3
[facet] fix argument inversion in date range facet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7612
diff
changeset
|
161 |
self.assertEqual(f.possible_values(), |
7629
58f11f7dad68
[range facet] closes #1806937: simply retrieve min/max values when computing vocabulary/possible_values, this is enough
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7624
diff
changeset
|
162 |
[str(mind), str(maxd)]) |
7615
e5ad51352eb3
[facet] fix argument inversion in date range facet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7612
diff
changeset
|
163 |
# ensure rqlst is left unmodified |
e5ad51352eb3
[facet] fix argument inversion in date range facet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7612
diff
changeset
|
164 |
self.assertEqual(rqlst.as_string(), 'DISTINCT Any WHERE X is CWUser') |
7629
58f11f7dad68
[range facet] closes #1806937: simply retrieve min/max values when computing vocabulary/possible_values, this is enough
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7624
diff
changeset
|
165 |
req.form['%s_inf' % f.__regid__] = str(datetime2ticks(mind)) |
58f11f7dad68
[range facet] closes #1806937: simply retrieve min/max values when computing vocabulary/possible_values, this is enough
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7624
diff
changeset
|
166 |
req.form['%s_sup' % f.__regid__] = str(datetime2ticks(mind)) |
7615
e5ad51352eb3
[facet] fix argument inversion in date range facet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7612
diff
changeset
|
167 |
f.add_rql_restrictions() |
e5ad51352eb3
[facet] fix argument inversion in date range facet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7612
diff
changeset
|
168 |
# selection is cluttered because rqlst has been prepared for facet (it |
e5ad51352eb3
[facet] fix argument inversion in date range facet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7612
diff
changeset
|
169 |
# is not in real life) |
e5ad51352eb3
[facet] fix argument inversion in date range facet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7612
diff
changeset
|
170 |
self.assertEqual(f.select.as_string(), |
e5ad51352eb3
[facet] fix argument inversion in date range facet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7612
diff
changeset
|
171 |
'DISTINCT Any WHERE X is CWUser, X creation_date >= "%s", ' |
e5ad51352eb3
[facet] fix argument inversion in date range facet
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7612
diff
changeset
|
172 |
'X creation_date <= "%s"' |
7629
58f11f7dad68
[range facet] closes #1806937: simply retrieve min/max values when computing vocabulary/possible_values, this is enough
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7624
diff
changeset
|
173 |
% (mind.strftime('%Y/%m/%d'), |
58f11f7dad68
[range facet] closes #1806937: simply retrieve min/max values when computing vocabulary/possible_values, this is enough
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7624
diff
changeset
|
174 |
mind.strftime('%Y/%m/%d'))) |
6119
b217635d3b28
new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
175 |
|
b217635d3b28
new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
176 |
def test_attribute(self): |
7605
48abeac162fd
[facets] refactor / cleanup facet api: more consistent variable naming and easier to reuse function. Closes #1796804
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7601
diff
changeset
|
177 |
req, rset, rqlst, filtered_variable = self.prepare_rqlst() |
6119
b217635d3b28
new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
178 |
f = facet.AttributeFacet(req, rset=rset, |
7605
48abeac162fd
[facets] refactor / cleanup facet api: more consistent variable naming and easier to reuse function. Closes #1796804
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7601
diff
changeset
|
179 |
select=rqlst.children[0], |
48abeac162fd
[facets] refactor / cleanup facet api: more consistent variable naming and easier to reuse function. Closes #1796804
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7601
diff
changeset
|
180 |
filtered_variable=filtered_variable) |
6119
b217635d3b28
new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
181 |
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
|
182 |
self.assertEqual(f.vocabulary(), |
6119
b217635d3b28
new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
183 |
[(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
|
184 |
# 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
|
185 |
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
|
186 |
#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
|
187 |
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
|
188 |
['admin', 'anon']) |
b217635d3b28
new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
189 |
# 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
|
190 |
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
|
191 |
req.form[f.__regid__] = 'admin' |
b217635d3b28
new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
192 |
f.add_rql_restrictions() |
b217635d3b28
new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
193 |
# 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
|
194 |
# is not in real life) |
7605
48abeac162fd
[facets] refactor / cleanup facet api: more consistent variable naming and easier to reuse function. Closes #1796804
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7601
diff
changeset
|
195 |
self.assertEqual(f.select.as_string(), |
6119
b217635d3b28
new RelationAttributeFacet + other fixes and cleanup + facets test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
196 |
"DISTINCT Any WHERE X is CWUser, X login 'admin'") |
6433
95c40961df21
[test] missing main
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
197 |
|
7618
5395007c415c
[facet] closes #1806931: new facet type, based on arbitrary rql path
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7615
diff
changeset
|
198 |
def test_rql_path_eid(self): |
5395007c415c
[facet] closes #1806931: new facet type, based on arbitrary rql path
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7615
diff
changeset
|
199 |
req, rset, rqlst, filtered_variable = self.prepare_rqlst() |
7874
be04706eacc9
[facet] add safety belt to rql path facet init (closes #1965481)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
7768
diff
changeset
|
200 |
class RPF(facet.RQLPathFacet): |
be04706eacc9
[facet] add safety belt to rql path facet init (closes #1965481)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
7768
diff
changeset
|
201 |
path = [('X created_by U'), ('U owned_by O'), ('O login OL')] |
be04706eacc9
[facet] add safety belt to rql path facet init (closes #1965481)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
7768
diff
changeset
|
202 |
filter_variable = 'O' |
be04706eacc9
[facet] add safety belt to rql path facet init (closes #1965481)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
7768
diff
changeset
|
203 |
label_variable = 'OL' |
be04706eacc9
[facet] add safety belt to rql path facet init (closes #1965481)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
7768
diff
changeset
|
204 |
f = RPF(req, rset=rset, select=rqlst.children[0], |
be04706eacc9
[facet] add safety belt to rql path facet init (closes #1965481)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
7768
diff
changeset
|
205 |
filtered_variable=filtered_variable) |
7618
5395007c415c
[facet] closes #1806931: new facet type, based on arbitrary rql path
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7615
diff
changeset
|
206 |
self.assertEqual(f.vocabulary(), [(u'admin', self.user().eid),]) |
5395007c415c
[facet] closes #1806931: new facet type, based on arbitrary rql path
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7615
diff
changeset
|
207 |
# ensure rqlst is left unmodified |
5395007c415c
[facet] closes #1806931: new facet type, based on arbitrary rql path
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7615
diff
changeset
|
208 |
self.assertEqual(rqlst.as_string(), 'DISTINCT Any WHERE X is CWUser') |
5395007c415c
[facet] closes #1806931: new facet type, based on arbitrary rql path
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7615
diff
changeset
|
209 |
#rqlst = rset.syntax_tree() |
5395007c415c
[facet] closes #1806931: new facet type, based on arbitrary rql path
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7615
diff
changeset
|
210 |
self.assertEqual(f.possible_values(), |
5395007c415c
[facet] closes #1806931: new facet type, based on arbitrary rql path
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7615
diff
changeset
|
211 |
[str(self.user().eid),]) |
5395007c415c
[facet] closes #1806931: new facet type, based on arbitrary rql path
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7615
diff
changeset
|
212 |
# ensure rqlst is left unmodified |
5395007c415c
[facet] closes #1806931: new facet type, based on arbitrary rql path
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7615
diff
changeset
|
213 |
self.assertEqual(rqlst.as_string(), 'DISTINCT Any WHERE X is CWUser') |
5395007c415c
[facet] closes #1806931: new facet type, based on arbitrary rql path
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7615
diff
changeset
|
214 |
req.form[f.__regid__] = '1' |
5395007c415c
[facet] closes #1806931: new facet type, based on arbitrary rql path
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7615
diff
changeset
|
215 |
f.add_rql_restrictions() |
5395007c415c
[facet] closes #1806931: new facet type, based on arbitrary rql path
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7615
diff
changeset
|
216 |
# selection is cluttered because rqlst has been prepared for facet (it |
5395007c415c
[facet] closes #1806931: new facet type, based on arbitrary rql path
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7615
diff
changeset
|
217 |
# is not in real life) |
5395007c415c
[facet] closes #1806931: new facet type, based on arbitrary rql path
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7615
diff
changeset
|
218 |
self.assertEqual(f.select.as_string(), |
5395007c415c
[facet] closes #1806931: new facet type, based on arbitrary rql path
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7615
diff
changeset
|
219 |
"DISTINCT Any WHERE X is CWUser, X created_by F, F owned_by G, G eid 1") |
5395007c415c
[facet] closes #1806931: new facet type, based on arbitrary rql path
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7615
diff
changeset
|
220 |
|
7874
be04706eacc9
[facet] add safety belt to rql path facet init (closes #1965481)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
7768
diff
changeset
|
221 |
def test_rql_path_eid_no_label(self): |
be04706eacc9
[facet] add safety belt to rql path facet init (closes #1965481)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
7768
diff
changeset
|
222 |
req, rset, rqlst, filtered_variable = self.prepare_rqlst() |
be04706eacc9
[facet] add safety belt to rql path facet init (closes #1965481)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
7768
diff
changeset
|
223 |
class RPF(facet.RQLPathFacet): |
be04706eacc9
[facet] add safety belt to rql path facet init (closes #1965481)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
7768
diff
changeset
|
224 |
path = [('X created_by U'), ('U owned_by O'), ('O login OL')] |
be04706eacc9
[facet] add safety belt to rql path facet init (closes #1965481)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
7768
diff
changeset
|
225 |
filter_variable = 'O' |
be04706eacc9
[facet] add safety belt to rql path facet init (closes #1965481)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
7768
diff
changeset
|
226 |
f = RPF(req, rset=rset, select=rqlst.children[0], |
be04706eacc9
[facet] add safety belt to rql path facet init (closes #1965481)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
7768
diff
changeset
|
227 |
filtered_variable=filtered_variable) |
be04706eacc9
[facet] add safety belt to rql path facet init (closes #1965481)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
7768
diff
changeset
|
228 |
self.assertEqual(f.vocabulary(), [(str(self.user().eid), self.user().eid),]) |
be04706eacc9
[facet] add safety belt to rql path facet init (closes #1965481)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
7768
diff
changeset
|
229 |
|
7618
5395007c415c
[facet] closes #1806931: new facet type, based on arbitrary rql path
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7615
diff
changeset
|
230 |
def test_rql_path_attr(self): |
5395007c415c
[facet] closes #1806931: new facet type, based on arbitrary rql path
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7615
diff
changeset
|
231 |
req, rset, rqlst, filtered_variable = self.prepare_rqlst() |
7874
be04706eacc9
[facet] add safety belt to rql path facet init (closes #1965481)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
7768
diff
changeset
|
232 |
class RPF(facet.RQLPathFacet): |
be04706eacc9
[facet] add safety belt to rql path facet init (closes #1965481)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
7768
diff
changeset
|
233 |
path = [('X created_by U'), ('U owned_by O'), ('O login OL')] |
be04706eacc9
[facet] add safety belt to rql path facet init (closes #1965481)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
7768
diff
changeset
|
234 |
filter_variable = 'OL' |
be04706eacc9
[facet] add safety belt to rql path facet init (closes #1965481)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
7768
diff
changeset
|
235 |
f = RPF(req, rset=rset, select=rqlst.children[0], |
be04706eacc9
[facet] add safety belt to rql path facet init (closes #1965481)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
7768
diff
changeset
|
236 |
filtered_variable=filtered_variable) |
7618
5395007c415c
[facet] closes #1806931: new facet type, based on arbitrary rql path
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7615
diff
changeset
|
237 |
|
5395007c415c
[facet] closes #1806931: new facet type, based on arbitrary rql path
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7615
diff
changeset
|
238 |
self.assertEqual(f.vocabulary(), [(u'admin', 'admin'),]) |
5395007c415c
[facet] closes #1806931: new facet type, based on arbitrary rql path
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7615
diff
changeset
|
239 |
# ensure rqlst is left unmodified |
5395007c415c
[facet] closes #1806931: new facet type, based on arbitrary rql path
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7615
diff
changeset
|
240 |
self.assertEqual(rqlst.as_string(), 'DISTINCT Any WHERE X is CWUser') |
5395007c415c
[facet] closes #1806931: new facet type, based on arbitrary rql path
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7615
diff
changeset
|
241 |
self.assertEqual(f.possible_values(), ['admin',]) |
5395007c415c
[facet] closes #1806931: new facet type, based on arbitrary rql path
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7615
diff
changeset
|
242 |
# ensure rqlst is left unmodified |
5395007c415c
[facet] closes #1806931: new facet type, based on arbitrary rql path
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7615
diff
changeset
|
243 |
self.assertEqual(rqlst.as_string(), 'DISTINCT Any WHERE X is CWUser') |
5395007c415c
[facet] closes #1806931: new facet type, based on arbitrary rql path
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7615
diff
changeset
|
244 |
req.form[f.__regid__] = 'admin' |
5395007c415c
[facet] closes #1806931: new facet type, based on arbitrary rql path
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7615
diff
changeset
|
245 |
f.add_rql_restrictions() |
5395007c415c
[facet] closes #1806931: new facet type, based on arbitrary rql path
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7615
diff
changeset
|
246 |
# selection is cluttered because rqlst has been prepared for facet (it |
5395007c415c
[facet] closes #1806931: new facet type, based on arbitrary rql path
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7615
diff
changeset
|
247 |
# is not in real life) |
5395007c415c
[facet] closes #1806931: new facet type, based on arbitrary rql path
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7615
diff
changeset
|
248 |
self.assertEqual(f.select.as_string(), |
5395007c415c
[facet] closes #1806931: new facet type, based on arbitrary rql path
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7615
diff
changeset
|
249 |
"DISTINCT Any WHERE X is CWUser, X created_by G, G owned_by H, H login 'admin'") |
5395007c415c
[facet] closes #1806931: new facet type, based on arbitrary rql path
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7615
diff
changeset
|
250 |
|
7874
be04706eacc9
[facet] add safety belt to rql path facet init (closes #1965481)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
7768
diff
changeset
|
251 |
def test_rql_path_check_filter_label_variable(self): |
be04706eacc9
[facet] add safety belt to rql path facet init (closes #1965481)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
7768
diff
changeset
|
252 |
req, rset, rqlst, filtered_variable = self.prepareg_aggregat_rqlst() |
be04706eacc9
[facet] add safety belt to rql path facet init (closes #1965481)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
7768
diff
changeset
|
253 |
class RPF(facet.RQLPathFacet): |
be04706eacc9
[facet] add safety belt to rql path facet init (closes #1965481)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
7768
diff
changeset
|
254 |
path = [('X created_by U'), ('U owned_by O'), ('O login OL')] |
be04706eacc9
[facet] add safety belt to rql path facet init (closes #1965481)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
7768
diff
changeset
|
255 |
filter_variable = 'OL' |
be04706eacc9
[facet] add safety belt to rql path facet init (closes #1965481)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
7768
diff
changeset
|
256 |
label_variable = 'OL' |
be04706eacc9
[facet] add safety belt to rql path facet init (closes #1965481)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
7768
diff
changeset
|
257 |
self.assertRaises(AssertionError, RPF, req, rset=rset, |
be04706eacc9
[facet] add safety belt to rql path facet init (closes #1965481)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
7768
diff
changeset
|
258 |
select=rqlst.children[0], |
be04706eacc9
[facet] add safety belt to rql path facet init (closes #1965481)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
7768
diff
changeset
|
259 |
filtered_variable=filtered_variable) |
be04706eacc9
[facet] add safety belt to rql path facet init (closes #1965481)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
7768
diff
changeset
|
260 |
|
7624
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
261 |
def prepareg_aggregat_rqlst(self): |
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
262 |
return self.prepare_rqlst( |
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
263 |
'Any 1, COUNT(X) WHERE X is CWUser, X creation_date XD, ' |
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
264 |
'X modification_date XM, Y creation_date YD, Y is CWGroup ' |
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
265 |
'HAVING DAY(XD)>=DAY(YD) AND DAY(XM)<=DAY(YD)', mainvar='X', |
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
266 |
baserql='DISTINCT Any WHERE X is CWUser, X creation_date XD, ' |
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
267 |
'X modification_date XM, Y creation_date YD, Y is CWGroup ' |
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
268 |
'HAVING DAY(XD) >= DAY(YD), DAY(XM) <= DAY(YD)', |
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
269 |
preparedrql='DISTINCT Any WHERE X is CWUser, X creation_date XD, ' |
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
270 |
'X modification_date XM, Y creation_date YD, Y is CWGroup ' |
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
271 |
'HAVING DAY(XD) >= DAY(YD), DAY(XM) <= DAY(YD)') |
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
272 |
|
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
273 |
|
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
274 |
def test_aggregat_query_cleanup_select(self): |
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
275 |
req, rset, rqlst, filtered_variable = self.prepareg_aggregat_rqlst() |
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
276 |
select = rqlst.children[0] |
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
277 |
facet.cleanup_select(select, filtered_variable=filtered_variable) |
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
278 |
self.assertEqual(select.as_string(), |
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
279 |
'DISTINCT Any WHERE X is CWUser, X creation_date XD, ' |
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
280 |
'X modification_date XM, Y creation_date YD, Y is CWGroup ' |
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
281 |
'HAVING DAY(XD) >= DAY(YD), DAY(XM) <= DAY(YD)') |
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
282 |
|
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
283 |
def test_aggregat_query_rql_path(self): |
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
284 |
req, rset, rqlst, filtered_variable = self.prepareg_aggregat_rqlst() |
7874
be04706eacc9
[facet] add safety belt to rql path facet init (closes #1965481)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
7768
diff
changeset
|
285 |
class RPF(facet.RQLPathFacet): |
be04706eacc9
[facet] add safety belt to rql path facet init (closes #1965481)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
7768
diff
changeset
|
286 |
path = [('X created_by U'), ('U owned_by O'), ('O login OL')] |
be04706eacc9
[facet] add safety belt to rql path facet init (closes #1965481)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
7768
diff
changeset
|
287 |
filter_variable = 'OL' |
be04706eacc9
[facet] add safety belt to rql path facet init (closes #1965481)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
7768
diff
changeset
|
288 |
f = RPF(req, rset=rset, select=rqlst.children[0], |
be04706eacc9
[facet] add safety belt to rql path facet init (closes #1965481)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
7768
diff
changeset
|
289 |
filtered_variable=filtered_variable) |
7624
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
290 |
self.assertEqual(f.vocabulary(), [(u'admin', u'admin')]) |
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
291 |
self.assertEqual(f.possible_values(), ['admin']) |
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
292 |
req.form[f.__regid__] = 'admin' |
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
293 |
f.add_rql_restrictions() |
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
294 |
self.assertEqual(f.select.as_string(), |
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
295 |
"DISTINCT Any WHERE X is CWUser, X creation_date XD, " |
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
296 |
"X modification_date XM, Y creation_date YD, Y is CWGroup, " |
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
297 |
"X created_by G, G owned_by H, H login 'admin' " |
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
298 |
"HAVING DAY(XD) >= DAY(YD), DAY(XM) <= DAY(YD)") |
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
299 |
|
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
300 |
def test_aggregat_query_attribute(self): |
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
301 |
req, rset, rqlst, filtered_variable = self.prepareg_aggregat_rqlst() |
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
302 |
f = facet.AttributeFacet(req, rset=rset, |
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
303 |
select=rqlst.children[0], |
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
304 |
filtered_variable=filtered_variable) |
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
305 |
f.rtype = 'login' |
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
306 |
self.assertEqual(f.vocabulary(), |
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
307 |
[(u'admin', u'admin'), (u'anon', u'anon')]) |
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
308 |
self.assertEqual(f.possible_values(), |
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
309 |
['admin', 'anon']) |
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
310 |
req.form[f.__regid__] = 'admin' |
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
311 |
f.add_rql_restrictions() |
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
312 |
self.assertEqual(f.select.as_string(), |
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
313 |
"DISTINCT Any WHERE X is CWUser, X creation_date XD, " |
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
314 |
"X modification_date XM, Y creation_date YD, Y is CWGroup, X login 'admin' " |
ce020f90fb8e
[facet] closes #1806932: test and fix facet bug w/ having query (need rql update)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7618
diff
changeset
|
315 |
"HAVING DAY(XD) >= DAY(YD), DAY(XM) <= DAY(YD)") |
6433
95c40961df21
[test] missing main
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
316 |
|
95c40961df21
[test] missing main
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
317 |
if __name__ == '__main__': |
95c40961df21
[test] missing main
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
318 |
from logilab.common.testlib import unittest_main |
95c40961df21
[test] missing main
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
319 |
unittest_main() |