author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Wed, 29 Jul 2009 09:08:26 +0200 | |
changeset 2550 | 4e009026a0f0 |
parent 2058 | 7ef12c03447c |
child 2661 | f8df42c9da6b |
permissions | -rw-r--r-- |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1723
diff
changeset
|
1 |
"""cubicweb.web.views.navigation unit tests |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1723
diff
changeset
|
2 |
|
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1723
diff
changeset
|
3 |
:organization: Logilab |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1723
diff
changeset
|
4 |
:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1723
diff
changeset
|
5 |
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1723
diff
changeset
|
6 |
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1723
diff
changeset
|
7 |
""" |
0 | 8 |
|
9 |
from logilab.common.testlib import unittest_main, mock_object |
|
10 |
from cubicweb.devtools.apptest import EnvBasedTC |
|
11 |
||
12 |
from cubicweb.web.views.navigation import PageNavigation, SortedNavigation |
|
47
54087a269bdd
fix tests (some where broken after ECache was added)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
16
diff
changeset
|
13 |
from cubicweb.web.views.ibreadcrumbs import BreadCrumbEntityVComponent |
0 | 14 |
|
47
54087a269bdd
fix tests (some where broken after ECache was added)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
16
diff
changeset
|
15 |
BreadCrumbEntityVComponent.visible = True |
0 | 16 |
|
17 |
class NavigationTC(EnvBasedTC): |
|
1723 | 18 |
|
0 | 19 |
def test_navigation_selection(self): |
20 |
rset = self.execute('Any X,N WHERE X name N') |
|
21 |
req = self.request() |
|
2058
7ef12c03447c
nicer vreg api, try to make rset an optional named argument in select and derivated (including selectors)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
22 |
navcomp = self.vreg.select('components', 'navigation', req, rset=rset) |
0 | 23 |
self.assertIsInstance(navcomp, PageNavigation) |
24 |
req.set_search_state('W:X:Y:Z') |
|
2058
7ef12c03447c
nicer vreg api, try to make rset an optional named argument in select and derivated (including selectors)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
25 |
navcomp = self.vreg.select('components', 'navigation', req, rset=rset) |
0 | 26 |
self.assertIsInstance(navcomp, PageNavigation) |
27 |
req.set_search_state('normal') |
|
28 |
rset = self.execute('Any X,N ORDERBY N WHERE X name N') |
|
2058
7ef12c03447c
nicer vreg api, try to make rset an optional named argument in select and derivated (including selectors)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
29 |
navcomp = self.vreg.select('components', 'navigation', req, rset=rset) |
0 | 30 |
self.assertIsInstance(navcomp, SortedNavigation) |
31 |
req.set_search_state('W:X:Y:Z') |
|
2058
7ef12c03447c
nicer vreg api, try to make rset an optional named argument in select and derivated (including selectors)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
32 |
navcomp = self.vreg.select('components', 'navigation', req, rset=rset) |
0 | 33 |
self.assertIsInstance(navcomp, SortedNavigation) |
34 |
req.set_search_state('normal') |
|
16
a70ece4d9d1a
fix tests in web/test
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
35 |
rset = self.execute('Any X,N LIMIT 10 WHERE X name N') |
2058
7ef12c03447c
nicer vreg api, try to make rset an optional named argument in select and derivated (including selectors)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
36 |
navcomp = self.vreg.select_object('components', 'navigation', req, rset=rset) |
0 | 37 |
self.assertEquals(navcomp, None) |
38 |
req.set_search_state('W:X:Y:Z') |
|
2058
7ef12c03447c
nicer vreg api, try to make rset an optional named argument in select and derivated (including selectors)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
39 |
navcomp = self.vreg.select_object('components', 'navigation', req, rset=rset) |
0 | 40 |
self.assertEquals(navcomp, None) |
41 |
req.set_search_state('normal') |
|
42 |
rset = self.execute('Any N, COUNT(RDEF) GROUPBY N ORDERBY N WHERE RDEF relation_type RT, RT name N') |
|
2058
7ef12c03447c
nicer vreg api, try to make rset an optional named argument in select and derivated (including selectors)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
43 |
navcomp = self.vreg.select('components', 'navigation', req, rset=rset) |
0 | 44 |
self.assertIsInstance(navcomp, SortedNavigation) |
45 |
req.set_search_state('W:X:Y:Z') |
|
2058
7ef12c03447c
nicer vreg api, try to make rset an optional named argument in select and derivated (including selectors)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
46 |
navcomp = self.vreg.select('components', 'navigation', req, rset=rset) |
0 | 47 |
self.assertIsInstance(navcomp, SortedNavigation) |
1723 | 48 |
|
49 |
||
0 | 50 |
def test_sorted_navigation(self): |
51 |
rset = self.execute('Any X,N ORDERBY N WHERE X name N') |
|
52 |
req = self.request() |
|
53 |
req.set_search_state('W:X:Y:Z') |
|
2058
7ef12c03447c
nicer vreg api, try to make rset an optional named argument in select and derivated (including selectors)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
54 |
navcomp = self.vreg.select('components', 'navigation', rset.req, rset=rset) |
1723 | 55 |
html = navcomp.render() |
0 | 56 |
rset = self.execute('Any RDEF ORDERBY RT WHERE RDEF relation_type RT') |
2058
7ef12c03447c
nicer vreg api, try to make rset an optional named argument in select and derivated (including selectors)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
57 |
navcomp = self.vreg.select('components', 'navigation', req, rset=rset) |
1723 | 58 |
html = navcomp.render() |
0 | 59 |
rset = self.execute('Any RDEF ORDERBY RDEF WHERE RDEF relation_type RT') |
2058
7ef12c03447c
nicer vreg api, try to make rset an optional named argument in select and derivated (including selectors)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
60 |
navcomp = self.vreg.select('components', 'navigation', req, rset=rset) |
1723 | 61 |
html = navcomp.render() |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
47
diff
changeset
|
62 |
rset = self.execute('CWAttribute RDEF ORDERBY RDEF') |
2058
7ef12c03447c
nicer vreg api, try to make rset an optional named argument in select and derivated (including selectors)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
63 |
navcomp = self.vreg.select('components', 'navigation', req, rset=rset) |
1723 | 64 |
html = navcomp.render() |
0 | 65 |
rset = self.execute('Any RDEF ORDERBY N WHERE RDEF relation_type RT, RT name N') |
2058
7ef12c03447c
nicer vreg api, try to make rset an optional named argument in select and derivated (including selectors)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
66 |
navcomp = self.vreg.select('components', 'navigation', req, rset=rset) |
1723 | 67 |
html = navcomp.render() |
0 | 68 |
rset = self.execute('Any N, COUNT(RDEF) GROUPBY N ORDERBY N WHERE RDEF relation_type RT, RT name N') |
2058
7ef12c03447c
nicer vreg api, try to make rset an optional named argument in select and derivated (including selectors)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
69 |
navcomp = self.vreg.select('components', 'navigation', rset.req, rset=rset) |
1723 | 70 |
html = navcomp.render() |
0 | 71 |
|
72 |
||
73 |
||
74 |
class ContentNavigationTC(EnvBasedTC): |
|
75 |
||
76 |
def test_component_context(self): |
|
77 |
view = mock_object(is_primary=lambda x: True) |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
47
diff
changeset
|
78 |
rset = self.execute('CWUser X LIMIT 1') |
0 | 79 |
req = self.request() |
2058
7ef12c03447c
nicer vreg api, try to make rset an optional named argument in select and derivated (including selectors)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
80 |
objs = self.vreg.possible_vobjects('contentnavigation', req, rset=rset, |
0 | 81 |
view=view, context='navtop') |
47
54087a269bdd
fix tests (some where broken after ECache was added)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
16
diff
changeset
|
82 |
# breadcrumbs should be in headers by default |
0 | 83 |
clsids = set(obj.id for obj in objs) |
47
54087a269bdd
fix tests (some where broken after ECache was added)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
16
diff
changeset
|
84 |
self.failUnless('breadcrumbs' in clsids) |
2058
7ef12c03447c
nicer vreg api, try to make rset an optional named argument in select and derivated (including selectors)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
85 |
objs = self.vreg.possible_vobjects('contentnavigation', req, rset=rset, |
0 | 86 |
view=view, context='navbottom') |
47
54087a269bdd
fix tests (some where broken after ECache was added)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
16
diff
changeset
|
87 |
# breadcrumbs should _NOT_ be in footers by default |
0 | 88 |
clsids = set(obj.id for obj in objs) |
47
54087a269bdd
fix tests (some where broken after ECache was added)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
16
diff
changeset
|
89 |
self.failIf('breadcrumbs' in clsids) |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
47
diff
changeset
|
90 |
self.execute('INSERT CWProperty P: P pkey "contentnavigation.breadcrumbs.context", ' |
0 | 91 |
'P value "navbottom"') |
47
54087a269bdd
fix tests (some where broken after ECache was added)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
16
diff
changeset
|
92 |
# breadcrumbs should now be in footers |
0 | 93 |
req.cnx.commit() |
2058
7ef12c03447c
nicer vreg api, try to make rset an optional named argument in select and derivated (including selectors)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
94 |
objs = self.vreg.possible_vobjects('contentnavigation', req, rset=rset, |
0 | 95 |
view=view, context='navbottom') |
1723 | 96 |
|
0 | 97 |
clsids = [obj.id for obj in objs] |
47
54087a269bdd
fix tests (some where broken after ECache was added)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
16
diff
changeset
|
98 |
self.failUnless('breadcrumbs' in clsids) |
2058
7ef12c03447c
nicer vreg api, try to make rset an optional named argument in select and derivated (including selectors)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
99 |
objs = self.vreg.possible_vobjects('contentnavigation', req, rset=rset, |
0 | 100 |
view=view, context='navtop') |
1723 | 101 |
|
0 | 102 |
clsids = [obj.id for obj in objs] |
47
54087a269bdd
fix tests (some where broken after ECache was added)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
16
diff
changeset
|
103 |
self.failIf('breadcrumbs' in clsids) |
1723 | 104 |
|
0 | 105 |
|
106 |
if __name__ == '__main__': |
|
107 |
unittest_main() |