author | Alexandre Fayolle <alexandre.fayolle@logilab.fr> |
Wed, 02 Jun 2010 18:12:27 +0200 | |
branch | stable |
changeset 5644 | 73d8a757db80 |
parent 5424 | 8ecbcbff9777 |
child 5623 | a01aa5b26e66 |
permissions | -rw-r--r-- |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
1 |
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
2 |
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
3 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
4 |
# This file is part of CubicWeb. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
5 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
6 |
# CubicWeb is free software: you can redistribute it and/or modify it under the |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
7 |
# terms of the GNU Lesser General Public License as published by the Free |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
8 |
# Software Foundation, either version 2.1 of the License, or (at your option) |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
9 |
# any later version. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
10 |
# |
5424
8ecbcbff9777
replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5421
diff
changeset
|
11 |
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
12 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
13 |
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
14 |
# details. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
15 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
16 |
# You should have received a copy of the GNU Lesser General Public License along |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
17 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1723
diff
changeset
|
18 |
"""cubicweb.web.views.navigation unit tests |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1723
diff
changeset
|
19 |
|
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1723
diff
changeset
|
20 |
""" |
0 | 21 |
|
22 |
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
|
23 |
from cubicweb.devtools.testlib import CubicWebTC |
0 | 24 |
|
25 |
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
|
26 |
from cubicweb.web.views.ibreadcrumbs import BreadCrumbEntityVComponent |
0 | 27 |
|
47
54087a269bdd
fix tests (some where broken after ECache was added)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
16
diff
changeset
|
28 |
BreadCrumbEntityVComponent.visible = True |
0 | 29 |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2721
diff
changeset
|
30 |
class NavigationTC(CubicWebTC): |
1723 | 31 |
|
2676
1282a15eb20f
[navigation] split tests, add test for __start out of bound
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2664
diff
changeset
|
32 |
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
|
33 |
req = self.request() |
0 | 34 |
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
|
35 |
navcomp = self.vreg['components'].select('navigation', req, rset=rset) |
0 | 36 |
self.assertIsInstance(navcomp, PageNavigation) |
37 |
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
|
38 |
navcomp = self.vreg['components'].select('navigation', req, rset=rset) |
0 | 39 |
self.assertIsInstance(navcomp, PageNavigation) |
40 |
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
|
41 |
|
1282a15eb20f
[navigation] split tests, add test for __start out of bound
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2664
diff
changeset
|
42 |
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
|
43 |
req = self.request() |
0 | 44 |
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
|
45 |
navcomp = self.vreg['components'].select('navigation', req, rset=rset) |
0 | 46 |
self.assertIsInstance(navcomp, SortedNavigation) |
47 |
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
|
48 |
navcomp = self.vreg['components'].select('navigation', req, rset=rset) |
0 | 49 |
self.assertIsInstance(navcomp, SortedNavigation) |
50 |
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
|
51 |
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
|
52 |
|
1282a15eb20f
[navigation] split tests, add test for __start out of bound
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2664
diff
changeset
|
53 |
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
|
54 |
req = self.request() |
16
a70ece4d9d1a
fix tests in web/test
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
55 |
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
|
56 |
navcomp = self.vreg['components'].select_or_none('navigation', req, rset=rset) |
0 | 57 |
self.assertEquals(navcomp, None) |
58 |
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
|
59 |
navcomp = self.vreg['components'].select_or_none('navigation', req, rset=rset) |
0 | 60 |
self.assertEquals(navcomp, None) |
61 |
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
|
62 |
|
1282a15eb20f
[navigation] split tests, add test for __start out of bound
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2664
diff
changeset
|
63 |
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
|
64 |
req = self.request() |
0 | 65 |
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
|
66 |
navcomp = self.vreg['components'].select('navigation', req, rset=rset) |
0 | 67 |
self.assertIsInstance(navcomp, SortedNavigation) |
68 |
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
|
69 |
navcomp = self.vreg['components'].select('navigation', req, rset=rset) |
0 | 70 |
self.assertIsInstance(navcomp, SortedNavigation) |
1723 | 71 |
|
2676
1282a15eb20f
[navigation] split tests, add test for __start out of bound
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2664
diff
changeset
|
72 |
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
|
73 |
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
|
74 |
rset = self.execute('Any X,N WHERE X name N') |
0 | 75 |
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
|
76 |
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
|
77 |
navcomp = self.vreg['components'].select('navigation', req, rset=rset) |
1723 | 78 |
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
|
79 |
|
1282a15eb20f
[navigation] split tests, add test for __start out of bound
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2664
diff
changeset
|
80 |
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
|
81 |
req = self.request() |
0 | 82 |
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
|
83 |
navcomp = self.vreg['components'].select('navigation', req, rset=rset) |
1723 | 84 |
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
|
85 |
|
1282a15eb20f
[navigation] split tests, add test for __start out of bound
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2664
diff
changeset
|
86 |
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
|
87 |
req = self.request() |
0 | 88 |
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
|
89 |
navcomp = self.vreg['components'].select('navigation', req, rset=rset) |
1723 | 90 |
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
|
91 |
|
1282a15eb20f
[navigation] split tests, add test for __start out of bound
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2664
diff
changeset
|
92 |
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
|
93 |
req = self.request() |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
47
diff
changeset
|
94 |
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
|
95 |
navcomp = self.vreg['components'].select('navigation', req, rset=rset) |
1723 | 96 |
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
|
97 |
|
1282a15eb20f
[navigation] split tests, add test for __start out of bound
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2664
diff
changeset
|
98 |
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
|
99 |
req = self.request() |
0 | 100 |
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
|
101 |
navcomp = self.vreg['components'].select('navigation', req, rset=rset) |
1723 | 102 |
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
|
103 |
|
1282a15eb20f
[navigation] split tests, add test for __start out of bound
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2664
diff
changeset
|
104 |
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
|
105 |
req = self.request() |
0 | 106 |
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
|
107 |
navcomp = self.vreg['components'].select('navigation', rset.req, rset=rset) |
1723 | 108 |
html = navcomp.render() |
0 | 109 |
|
110 |
||
3224
56d4104b4261
comment out deprecated test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2721
diff
changeset
|
111 |
# XXX deactivate, contextual component has been removed |
3230 | 112 |
# class ContentNavigationTC(CubicWebTC): |
113 |
# def test_component_context(self): |
|
114 |
# view = mock_object(is_primary=lambda x: True) |
|
115 |
# rset = self.execute('CWUser X LIMIT 1') |
|
116 |
# req = self.request() |
|
117 |
# objs = self.vreg['contentnavigation'].poss_visible_objects( |
|
118 |
# req, rset=rset, view=view, context='navtop') |
|
119 |
# # breadcrumbs should be in headers by default |
|
120 |
# clsids = set(obj.id for obj in objs) |
|
121 |
# self.failUnless('breadcrumbs' in clsids) |
|
122 |
# objs = self.vreg['contentnavigation'].poss_visible_objects( |
|
123 |
# req, rset=rset, view=view, context='navbottom') |
|
124 |
# # breadcrumbs should _NOT_ be in footers by default |
|
125 |
# clsids = set(obj.id for obj in objs) |
|
126 |
# self.failIf('breadcrumbs' in clsids) |
|
127 |
# self.execute('INSERT CWProperty P: P pkey "contentnavigation.breadcrumbs.context", ' |
|
128 |
# 'P value "navbottom"') |
|
129 |
# # breadcrumbs should now be in footers |
|
130 |
# req.cnx.commit() |
|
131 |
# objs = self.vreg['contentnavigation'].poss_visible_objects( |
|
132 |
# req, rset=rset, view=view, context='navbottom') |
|
0 | 133 |
|
3230 | 134 |
# clsids = [obj.id for obj in objs] |
135 |
# self.failUnless('breadcrumbs' in clsids) |
|
136 |
# objs = self.vreg['contentnavigation'].poss_visible_objects( |
|
137 |
# req, rset=rset, view=view, context='navtop') |
|
1723 | 138 |
|
3230 | 139 |
# clsids = [obj.id for obj in objs] |
140 |
# self.failIf('breadcrumbs' in clsids) |
|
1723 | 141 |
|
0 | 142 |
|
143 |
if __name__ == '__main__': |
|
144 |
unittest_main() |