author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Mon, 29 Mar 2010 10:20:01 +0200 | |
branch | stable |
changeset 5054 | cb066d29166a |
parent 4252 | 6c4f109c2b03 |
child 5421 | 8167de96c523 |
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 |
4212
ab6573088b4a
update copyright: welcome 2010
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3224
diff
changeset
|
4 |
:copyright: 2001-2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
1977
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 |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2721
diff
changeset
|
10 |
from cubicweb.devtools.testlib import CubicWebTC |
0 | 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 |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2721
diff
changeset
|
17 |
class NavigationTC(CubicWebTC): |
1723 | 18 |
|
2676
1282a15eb20f
[navigation] split tests, add test for __start out of bound
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2664
diff
changeset
|
19 |
def test_navigation_selection_whatever(self): |
1282a15eb20f
[navigation] split tests, add test for __start out of bound
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2664
diff
changeset
|
20 |
req = self.request() |
0 | 21 |
rset = self.execute('Any X,N WHERE X name N') |
2661
f8df42c9da6b
[vreg api update] remove some deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2058
diff
changeset
|
22 |
navcomp = self.vreg['components'].select('navigation', req, rset=rset) |
0 | 23 |
self.assertIsInstance(navcomp, PageNavigation) |
24 |
req.set_search_state('W:X:Y:Z') |
|
2661
f8df42c9da6b
[vreg api update] remove some deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2058
diff
changeset
|
25 |
navcomp = self.vreg['components'].select('navigation', req, rset=rset) |
0 | 26 |
self.assertIsInstance(navcomp, PageNavigation) |
27 |
req.set_search_state('normal') |
|
2676
1282a15eb20f
[navigation] split tests, add test for __start out of bound
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2664
diff
changeset
|
28 |
|
1282a15eb20f
[navigation] split tests, add test for __start out of bound
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2664
diff
changeset
|
29 |
def test_navigation_selection_ordered(self): |
1282a15eb20f
[navigation] split tests, add test for __start out of bound
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2664
diff
changeset
|
30 |
req = self.request() |
0 | 31 |
rset = self.execute('Any X,N ORDERBY N WHERE X name N') |
2661
f8df42c9da6b
[vreg api update] remove some deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2058
diff
changeset
|
32 |
navcomp = self.vreg['components'].select('navigation', req, rset=rset) |
0 | 33 |
self.assertIsInstance(navcomp, SortedNavigation) |
34 |
req.set_search_state('W:X:Y:Z') |
|
2661
f8df42c9da6b
[vreg api update] remove some deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2058
diff
changeset
|
35 |
navcomp = self.vreg['components'].select('navigation', req, rset=rset) |
0 | 36 |
self.assertIsInstance(navcomp, SortedNavigation) |
37 |
req.set_search_state('normal') |
|
2676
1282a15eb20f
[navigation] split tests, add test for __start out of bound
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2664
diff
changeset
|
38 |
html = navcomp.render() |
1282a15eb20f
[navigation] split tests, add test for __start out of bound
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2664
diff
changeset
|
39 |
|
1282a15eb20f
[navigation] split tests, add test for __start out of bound
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2664
diff
changeset
|
40 |
def test_navigation_selection_not_enough(self): |
1282a15eb20f
[navigation] split tests, add test for __start out of bound
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2664
diff
changeset
|
41 |
req = self.request() |
16
a70ece4d9d1a
fix tests in web/test
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
42 |
rset = self.execute('Any X,N LIMIT 10 WHERE X name N') |
2770
356e9d7c356d
R propagate registry API changes
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2721
diff
changeset
|
43 |
navcomp = self.vreg['components'].select_or_none('navigation', req, rset=rset) |
0 | 44 |
self.assertEquals(navcomp, None) |
45 |
req.set_search_state('W:X:Y:Z') |
|
2770
356e9d7c356d
R propagate registry API changes
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2721
diff
changeset
|
46 |
navcomp = self.vreg['components'].select_or_none('navigation', req, rset=rset) |
0 | 47 |
self.assertEquals(navcomp, None) |
48 |
req.set_search_state('normal') |
|
2676
1282a15eb20f
[navigation] split tests, add test for __start out of bound
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2664
diff
changeset
|
49 |
|
1282a15eb20f
[navigation] split tests, add test for __start out of bound
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2664
diff
changeset
|
50 |
def test_navigation_selection_not_enough(self): |
1282a15eb20f
[navigation] split tests, add test for __start out of bound
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2664
diff
changeset
|
51 |
req = self.request() |
0 | 52 |
rset = self.execute('Any N, COUNT(RDEF) GROUPBY N ORDERBY N WHERE RDEF relation_type RT, RT name N') |
2661
f8df42c9da6b
[vreg api update] remove some deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2058
diff
changeset
|
53 |
navcomp = self.vreg['components'].select('navigation', req, rset=rset) |
0 | 54 |
self.assertIsInstance(navcomp, SortedNavigation) |
55 |
req.set_search_state('W:X:Y:Z') |
|
2661
f8df42c9da6b
[vreg api update] remove some deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2058
diff
changeset
|
56 |
navcomp = self.vreg['components'].select('navigation', req, rset=rset) |
0 | 57 |
self.assertIsInstance(navcomp, SortedNavigation) |
1723 | 58 |
|
2676
1282a15eb20f
[navigation] split tests, add test for __start out of bound
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2664
diff
changeset
|
59 |
def test_navigation_selection_wrong_boundary(self): |
1282a15eb20f
[navigation] split tests, add test for __start out of bound
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2664
diff
changeset
|
60 |
req = self.request() |
1282a15eb20f
[navigation] split tests, add test for __start out of bound
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2664
diff
changeset
|
61 |
rset = self.execute('Any X,N WHERE X name N') |
0 | 62 |
req = self.request() |
2676
1282a15eb20f
[navigation] split tests, add test for __start out of bound
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2664
diff
changeset
|
63 |
req.form['__start'] = 1000000 |
1282a15eb20f
[navigation] split tests, add test for __start out of bound
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2664
diff
changeset
|
64 |
navcomp = self.vreg['components'].select('navigation', req, rset=rset) |
1723 | 65 |
html = navcomp.render() |
2676
1282a15eb20f
[navigation] split tests, add test for __start out of bound
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2664
diff
changeset
|
66 |
|
1282a15eb20f
[navigation] split tests, add test for __start out of bound
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2664
diff
changeset
|
67 |
def test_sorted_navigation_1(self): |
1282a15eb20f
[navigation] split tests, add test for __start out of bound
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2664
diff
changeset
|
68 |
req = self.request() |
0 | 69 |
rset = self.execute('Any RDEF ORDERBY RT WHERE RDEF relation_type RT') |
2661
f8df42c9da6b
[vreg api update] remove some deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2058
diff
changeset
|
70 |
navcomp = self.vreg['components'].select('navigation', req, rset=rset) |
1723 | 71 |
html = navcomp.render() |
2676
1282a15eb20f
[navigation] split tests, add test for __start out of bound
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2664
diff
changeset
|
72 |
|
1282a15eb20f
[navigation] split tests, add test for __start out of bound
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2664
diff
changeset
|
73 |
def test_sorted_navigation_2(self): |
1282a15eb20f
[navigation] split tests, add test for __start out of bound
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2664
diff
changeset
|
74 |
req = self.request() |
0 | 75 |
rset = self.execute('Any RDEF ORDERBY RDEF WHERE RDEF relation_type RT') |
2661
f8df42c9da6b
[vreg api update] remove some deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2058
diff
changeset
|
76 |
navcomp = self.vreg['components'].select('navigation', req, rset=rset) |
1723 | 77 |
html = navcomp.render() |
2676
1282a15eb20f
[navigation] split tests, add test for __start out of bound
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2664
diff
changeset
|
78 |
|
1282a15eb20f
[navigation] split tests, add test for __start out of bound
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2664
diff
changeset
|
79 |
def test_sorted_navigation_3(self): |
1282a15eb20f
[navigation] split tests, add test for __start out of bound
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2664
diff
changeset
|
80 |
req = self.request() |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
47
diff
changeset
|
81 |
rset = self.execute('CWAttribute RDEF ORDERBY RDEF') |
2661
f8df42c9da6b
[vreg api update] remove some deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2058
diff
changeset
|
82 |
navcomp = self.vreg['components'].select('navigation', req, rset=rset) |
1723 | 83 |
html = navcomp.render() |
2676
1282a15eb20f
[navigation] split tests, add test for __start out of bound
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2664
diff
changeset
|
84 |
|
1282a15eb20f
[navigation] split tests, add test for __start out of bound
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2664
diff
changeset
|
85 |
def test_sorted_navigation_4(self): |
1282a15eb20f
[navigation] split tests, add test for __start out of bound
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2664
diff
changeset
|
86 |
req = self.request() |
0 | 87 |
rset = self.execute('Any RDEF ORDERBY N WHERE RDEF relation_type RT, RT name N') |
2661
f8df42c9da6b
[vreg api update] remove some deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2058
diff
changeset
|
88 |
navcomp = self.vreg['components'].select('navigation', req, rset=rset) |
1723 | 89 |
html = navcomp.render() |
2676
1282a15eb20f
[navigation] split tests, add test for __start out of bound
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2664
diff
changeset
|
90 |
|
1282a15eb20f
[navigation] split tests, add test for __start out of bound
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2664
diff
changeset
|
91 |
def test_sorted_navigation_5(self): |
1282a15eb20f
[navigation] split tests, add test for __start out of bound
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2664
diff
changeset
|
92 |
req = self.request() |
0 | 93 |
rset = self.execute('Any N, COUNT(RDEF) GROUPBY N ORDERBY N WHERE RDEF relation_type RT, RT name N') |
2661
f8df42c9da6b
[vreg api update] remove some deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2058
diff
changeset
|
94 |
navcomp = self.vreg['components'].select('navigation', rset.req, rset=rset) |
1723 | 95 |
html = navcomp.render() |
0 | 96 |
|
97 |
||
3224
56d4104b4261
comment out deprecated test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2721
diff
changeset
|
98 |
# XXX deactivate, contextual component has been removed |
3230 | 99 |
# class ContentNavigationTC(CubicWebTC): |
100 |
# def test_component_context(self): |
|
101 |
# view = mock_object(is_primary=lambda x: True) |
|
102 |
# rset = self.execute('CWUser X LIMIT 1') |
|
103 |
# req = self.request() |
|
104 |
# objs = self.vreg['contentnavigation'].poss_visible_objects( |
|
105 |
# req, rset=rset, view=view, context='navtop') |
|
106 |
# # breadcrumbs should be in headers by default |
|
107 |
# clsids = set(obj.id for obj in objs) |
|
108 |
# self.failUnless('breadcrumbs' in clsids) |
|
109 |
# objs = self.vreg['contentnavigation'].poss_visible_objects( |
|
110 |
# req, rset=rset, view=view, context='navbottom') |
|
111 |
# # breadcrumbs should _NOT_ be in footers by default |
|
112 |
# clsids = set(obj.id for obj in objs) |
|
113 |
# self.failIf('breadcrumbs' in clsids) |
|
114 |
# self.execute('INSERT CWProperty P: P pkey "contentnavigation.breadcrumbs.context", ' |
|
115 |
# 'P value "navbottom"') |
|
116 |
# # breadcrumbs should now be in footers |
|
117 |
# req.cnx.commit() |
|
118 |
# objs = self.vreg['contentnavigation'].poss_visible_objects( |
|
119 |
# req, rset=rset, view=view, context='navbottom') |
|
0 | 120 |
|
3230 | 121 |
# clsids = [obj.id for obj in objs] |
122 |
# self.failUnless('breadcrumbs' in clsids) |
|
123 |
# objs = self.vreg['contentnavigation'].poss_visible_objects( |
|
124 |
# req, rset=rset, view=view, context='navtop') |
|
1723 | 125 |
|
3230 | 126 |
# clsids = [obj.id for obj in objs] |
127 |
# self.failIf('breadcrumbs' in clsids) |
|
1723 | 128 |
|
0 | 129 |
|
130 |
if __name__ == '__main__': |
|
131 |
unittest_main() |