author | Alexandre Fayolle <alexandre.fayolle@logilab.fr> |
Mon, 23 Aug 2010 12:49:28 +0200 | |
branch | stable |
changeset 6135 | e4b37742f75a |
parent 5623 | a01aa5b26e66 |
child 6141 | b8287e54b528 |
child 6340 | 470d8e828fda |
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/>. |
5623
a01aa5b26e66
[test] update test to follow recent navigation/facets fixes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
18 |
"""cubicweb.web.views.navigation unit tests""" |
0 | 19 |
|
20 |
from logilab.common.testlib import unittest_main, mock_object |
|
5623
a01aa5b26e66
[test] update test to follow recent navigation/facets fixes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
21 |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2721
diff
changeset
|
22 |
from cubicweb.devtools.testlib import CubicWebTC |
5623
a01aa5b26e66
[test] update test to follow recent navigation/facets fixes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
23 |
from cubicweb.web.views.navigation import (PageNavigation, SortedNavigation, |
a01aa5b26e66
[test] update test to follow recent navigation/facets fixes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
24 |
PageNavigationSelect) |
47
54087a269bdd
fix tests (some where broken after ECache was added)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
16
diff
changeset
|
25 |
from cubicweb.web.views.ibreadcrumbs import BreadCrumbEntityVComponent |
0 | 26 |
|
47
54087a269bdd
fix tests (some where broken after ECache was added)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
16
diff
changeset
|
27 |
BreadCrumbEntityVComponent.visible = True |
0 | 28 |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2721
diff
changeset
|
29 |
class NavigationTC(CubicWebTC): |
1723 | 30 |
|
2676
1282a15eb20f
[navigation] split tests, add test for __start out of bound
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2664
diff
changeset
|
31 |
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
|
32 |
req = self.request() |
0 | 33 |
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
|
34 |
navcomp = self.vreg['components'].select('navigation', req, rset=rset) |
0 | 35 |
self.assertIsInstance(navcomp, PageNavigation) |
36 |
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
|
37 |
navcomp = self.vreg['components'].select('navigation', req, rset=rset) |
0 | 38 |
self.assertIsInstance(navcomp, PageNavigation) |
39 |
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
|
40 |
|
1282a15eb20f
[navigation] split tests, add test for __start out of bound
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2664
diff
changeset
|
41 |
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
|
42 |
req = self.request() |
5623
a01aa5b26e66
[test] update test to follow recent navigation/facets fixes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
43 |
rset = self.execute('Any X,N ORDERBY N LIMIT 40 WHERE X name N') |
a01aa5b26e66
[test] update test to follow recent navigation/facets fixes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
44 |
navcomp = self.vreg['components'].select('navigation', req, rset=rset, page_size=20) |
0 | 45 |
self.assertIsInstance(navcomp, SortedNavigation) |
46 |
req.set_search_state('W:X:Y:Z') |
|
5623
a01aa5b26e66
[test] update test to follow recent navigation/facets fixes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
47 |
navcomp = self.vreg['components'].select('navigation', req, rset=rset, page_size=20) |
0 | 48 |
self.assertIsInstance(navcomp, SortedNavigation) |
49 |
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
|
50 |
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
|
51 |
|
5623
a01aa5b26e66
[test] update test to follow recent navigation/facets fixes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
52 |
def test_navigation_selection_large_rset(self): |
a01aa5b26e66
[test] update test to follow recent navigation/facets fixes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
53 |
req = self.request() |
a01aa5b26e66
[test] update test to follow recent navigation/facets fixes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
54 |
rset = self.execute('Any X,N LIMIT 120 WHERE X name N') |
a01aa5b26e66
[test] update test to follow recent navigation/facets fixes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
55 |
navcomp = self.vreg['components'].select('navigation', req, rset=rset, page_size=20) |
a01aa5b26e66
[test] update test to follow recent navigation/facets fixes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
56 |
self.assertIsInstance(navcomp, PageNavigationSelect) |
a01aa5b26e66
[test] update test to follow recent navigation/facets fixes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
57 |
rset = self.execute('Any X,N ORDERBY N LIMIT 120 WHERE X name N') |
a01aa5b26e66
[test] update test to follow recent navigation/facets fixes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
58 |
navcomp = self.vreg['components'].select('navigation', req, rset=rset, page_size=20) |
a01aa5b26e66
[test] update test to follow recent navigation/facets fixes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
59 |
self.assertIsInstance(navcomp, PageNavigationSelect) |
a01aa5b26e66
[test] update test to follow recent navigation/facets fixes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
60 |
|
2676
1282a15eb20f
[navigation] split tests, add test for __start out of bound
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2664
diff
changeset
|
61 |
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
|
62 |
req = self.request() |
16
a70ece4d9d1a
fix tests in web/test
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
63 |
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
|
64 |
navcomp = self.vreg['components'].select_or_none('navigation', req, rset=rset) |
0 | 65 |
self.assertEquals(navcomp, None) |
66 |
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
|
67 |
navcomp = self.vreg['components'].select_or_none('navigation', req, rset=rset) |
0 | 68 |
self.assertEquals(navcomp, None) |
69 |
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
|
70 |
|
1282a15eb20f
[navigation] split tests, add test for __start out of bound
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2664
diff
changeset
|
71 |
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
|
72 |
req = self.request() |
0 | 73 |
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
|
74 |
navcomp = self.vreg['components'].select('navigation', req, rset=rset) |
0 | 75 |
self.assertIsInstance(navcomp, SortedNavigation) |
76 |
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
|
77 |
navcomp = self.vreg['components'].select('navigation', req, rset=rset) |
0 | 78 |
self.assertIsInstance(navcomp, SortedNavigation) |
1723 | 79 |
|
2676
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_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
|
81 |
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
|
82 |
rset = self.execute('Any X,N WHERE X name N') |
0 | 83 |
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
|
84 |
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
|
85 |
navcomp = self.vreg['components'].select('navigation', req, rset=rset) |
1723 | 86 |
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
|
87 |
|
1282a15eb20f
[navigation] split tests, add test for __start out of bound
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2664
diff
changeset
|
88 |
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
|
89 |
req = self.request() |
0 | 90 |
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
|
91 |
navcomp = self.vreg['components'].select('navigation', req, rset=rset) |
1723 | 92 |
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
|
93 |
|
1282a15eb20f
[navigation] split tests, add test for __start out of bound
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2664
diff
changeset
|
94 |
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
|
95 |
req = self.request() |
0 | 96 |
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
|
97 |
navcomp = self.vreg['components'].select('navigation', req, rset=rset) |
1723 | 98 |
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
|
99 |
|
1282a15eb20f
[navigation] split tests, add test for __start out of bound
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2664
diff
changeset
|
100 |
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
|
101 |
req = self.request() |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
47
diff
changeset
|
102 |
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
|
103 |
navcomp = self.vreg['components'].select('navigation', req, rset=rset) |
1723 | 104 |
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
|
105 |
|
1282a15eb20f
[navigation] split tests, add test for __start out of bound
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2664
diff
changeset
|
106 |
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
|
107 |
req = self.request() |
0 | 108 |
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
|
109 |
navcomp = self.vreg['components'].select('navigation', req, rset=rset) |
1723 | 110 |
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
|
111 |
|
1282a15eb20f
[navigation] split tests, add test for __start out of bound
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2664
diff
changeset
|
112 |
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
|
113 |
req = self.request() |
0 | 114 |
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
|
115 |
navcomp = self.vreg['components'].select('navigation', rset.req, rset=rset) |
1723 | 116 |
html = navcomp.render() |
0 | 117 |
|
118 |
||
3224
56d4104b4261
comment out deprecated test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2721
diff
changeset
|
119 |
# XXX deactivate, contextual component has been removed |
3230 | 120 |
# class ContentNavigationTC(CubicWebTC): |
121 |
# def test_component_context(self): |
|
122 |
# view = mock_object(is_primary=lambda x: True) |
|
123 |
# rset = self.execute('CWUser X LIMIT 1') |
|
124 |
# req = self.request() |
|
125 |
# objs = self.vreg['contentnavigation'].poss_visible_objects( |
|
126 |
# req, rset=rset, view=view, context='navtop') |
|
127 |
# # breadcrumbs should be in headers by default |
|
128 |
# clsids = set(obj.id for obj in objs) |
|
129 |
# self.failUnless('breadcrumbs' in clsids) |
|
130 |
# objs = self.vreg['contentnavigation'].poss_visible_objects( |
|
131 |
# req, rset=rset, view=view, context='navbottom') |
|
132 |
# # breadcrumbs should _NOT_ be in footers by default |
|
133 |
# clsids = set(obj.id for obj in objs) |
|
134 |
# self.failIf('breadcrumbs' in clsids) |
|
135 |
# self.execute('INSERT CWProperty P: P pkey "contentnavigation.breadcrumbs.context", ' |
|
136 |
# 'P value "navbottom"') |
|
137 |
# # breadcrumbs should now be in footers |
|
138 |
# req.cnx.commit() |
|
139 |
# objs = self.vreg['contentnavigation'].poss_visible_objects( |
|
140 |
# req, rset=rset, view=view, context='navbottom') |
|
0 | 141 |
|
3230 | 142 |
# clsids = [obj.id for obj in objs] |
143 |
# self.failUnless('breadcrumbs' in clsids) |
|
144 |
# objs = self.vreg['contentnavigation'].poss_visible_objects( |
|
145 |
# req, rset=rset, view=view, context='navtop') |
|
1723 | 146 |
|
3230 | 147 |
# clsids = [obj.id for obj in objs] |
148 |
# self.failIf('breadcrumbs' in clsids) |
|
1723 | 149 |
|
0 | 150 |
|
151 |
if __name__ == '__main__': |
|
152 |
unittest_main() |