author | Adrien Di Mascio <Adrien.DiMascio@logilab.fr> |
Wed, 27 May 2009 08:39:16 +0200 | |
changeset 1956 | 9865daa96cd7 |
parent 1723 | 30c3a713ab61 |
child 1977 | 606923dff11b |
permissions | -rw-r--r-- |
0 | 1 |
"""cubicweb.web.views.navigation unit tests""" |
2 |
||
3 |
from logilab.common.testlib import unittest_main, mock_object |
|
4 |
from cubicweb.devtools.apptest import EnvBasedTC |
|
5 |
||
6 |
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
|
7 |
from cubicweb.web.views.ibreadcrumbs import BreadCrumbEntityVComponent |
0 | 8 |
|
47
54087a269bdd
fix tests (some where broken after ECache was added)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
16
diff
changeset
|
9 |
BreadCrumbEntityVComponent.visible = True |
0 | 10 |
|
11 |
class NavigationTC(EnvBasedTC): |
|
1723 | 12 |
|
0 | 13 |
def test_navigation_selection(self): |
14 |
rset = self.execute('Any X,N WHERE X name N') |
|
15 |
req = self.request() |
|
16 |
navcomp = self.vreg.select_component('navigation', req, rset) |
|
17 |
self.assertIsInstance(navcomp, PageNavigation) |
|
18 |
req.set_search_state('W:X:Y:Z') |
|
19 |
navcomp = self.vreg.select_component('navigation', req, rset) |
|
20 |
self.assertIsInstance(navcomp, PageNavigation) |
|
21 |
req.set_search_state('normal') |
|
22 |
rset = self.execute('Any X,N ORDERBY N WHERE X name N') |
|
23 |
navcomp = self.vreg.select_component('navigation', req, rset) |
|
24 |
self.assertIsInstance(navcomp, SortedNavigation) |
|
25 |
req.set_search_state('W:X:Y:Z') |
|
26 |
navcomp = self.vreg.select_component('navigation', req, rset) |
|
27 |
self.assertIsInstance(navcomp, SortedNavigation) |
|
28 |
req.set_search_state('normal') |
|
16
a70ece4d9d1a
fix tests in web/test
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
29 |
rset = self.execute('Any X,N LIMIT 10 WHERE X name N') |
0 | 30 |
navcomp = self.vreg.select_component('navigation', req, rset) |
31 |
self.assertEquals(navcomp, None) |
|
32 |
req.set_search_state('W:X:Y:Z') |
|
33 |
navcomp = self.vreg.select_component('navigation', req, rset) |
|
34 |
self.assertEquals(navcomp, None) |
|
35 |
req.set_search_state('normal') |
|
36 |
rset = self.execute('Any N, COUNT(RDEF) GROUPBY N ORDERBY N WHERE RDEF relation_type RT, RT name N') |
|
37 |
navcomp = self.vreg.select_component('navigation', req, rset) |
|
38 |
self.assertIsInstance(navcomp, SortedNavigation) |
|
39 |
req.set_search_state('W:X:Y:Z') |
|
40 |
navcomp = self.vreg.select_component('navigation', req, rset) |
|
41 |
self.assertIsInstance(navcomp, SortedNavigation) |
|
1723 | 42 |
|
43 |
||
0 | 44 |
def test_sorted_navigation(self): |
45 |
rset = self.execute('Any X,N ORDERBY N WHERE X name N') |
|
46 |
req = self.request() |
|
47 |
req.set_search_state('W:X:Y:Z') |
|
48 |
navcomp = self.vreg.select_component('navigation', rset.req, rset) |
|
1723 | 49 |
html = navcomp.render() |
0 | 50 |
rset = self.execute('Any RDEF ORDERBY RT WHERE RDEF relation_type RT') |
51 |
navcomp = self.vreg.select_component('navigation', req, rset) |
|
1723 | 52 |
html = navcomp.render() |
0 | 53 |
rset = self.execute('Any RDEF ORDERBY RDEF WHERE RDEF relation_type RT') |
54 |
navcomp = self.vreg.select_component('navigation', req, rset) |
|
1723 | 55 |
html = navcomp.render() |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
47
diff
changeset
|
56 |
rset = self.execute('CWAttribute RDEF ORDERBY RDEF') |
0 | 57 |
navcomp = self.vreg.select_component('navigation', req, rset) |
1723 | 58 |
html = navcomp.render() |
0 | 59 |
rset = self.execute('Any RDEF ORDERBY N WHERE RDEF relation_type RT, RT name N') |
60 |
navcomp = self.vreg.select_component('navigation', req, rset) |
|
1723 | 61 |
html = navcomp.render() |
0 | 62 |
rset = self.execute('Any N, COUNT(RDEF) GROUPBY N ORDERBY N WHERE RDEF relation_type RT, RT name N') |
63 |
navcomp = self.vreg.select_component('navigation', rset.req, rset) |
|
1723 | 64 |
html = navcomp.render() |
0 | 65 |
|
66 |
||
67 |
||
68 |
class ContentNavigationTC(EnvBasedTC): |
|
69 |
||
70 |
def test_component_context(self): |
|
71 |
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
|
72 |
rset = self.execute('CWUser X LIMIT 1') |
0 | 73 |
req = self.request() |
74 |
objs = self.vreg.possible_vobjects('contentnavigation', req, rset, |
|
75 |
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
|
76 |
# breadcrumbs should be in headers by default |
0 | 77 |
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
|
78 |
self.failUnless('breadcrumbs' in clsids) |
0 | 79 |
objs = self.vreg.possible_vobjects('contentnavigation', req, rset, |
80 |
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
|
81 |
# breadcrumbs should _NOT_ be in footers by default |
0 | 82 |
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
|
83 |
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
|
84 |
self.execute('INSERT CWProperty P: P pkey "contentnavigation.breadcrumbs.context", ' |
0 | 85 |
'P value "navbottom"') |
47
54087a269bdd
fix tests (some where broken after ECache was added)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
16
diff
changeset
|
86 |
# breadcrumbs should now be in footers |
0 | 87 |
req.cnx.commit() |
88 |
objs = self.vreg.possible_vobjects('contentnavigation', req, rset, |
|
89 |
view=view, context='navbottom') |
|
1723 | 90 |
|
0 | 91 |
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
|
92 |
self.failUnless('breadcrumbs' in clsids) |
0 | 93 |
objs = self.vreg.possible_vobjects('contentnavigation', req, rset, |
94 |
view=view, context='navtop') |
|
1723 | 95 |
|
0 | 96 |
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
|
97 |
self.failIf('breadcrumbs' in clsids) |
1723 | 98 |
|
0 | 99 |
|
100 |
if __name__ == '__main__': |
|
101 |
unittest_main() |