2 |
2 |
3 from logilab.common.testlib import unittest_main, mock_object |
3 from logilab.common.testlib import unittest_main, mock_object |
4 from cubicweb.devtools.apptest import EnvBasedTC |
4 from cubicweb.devtools.apptest import EnvBasedTC |
5 |
5 |
6 from cubicweb.web.views.navigation import PageNavigation, SortedNavigation |
6 from cubicweb.web.views.navigation import PageNavigation, SortedNavigation |
|
7 from cubicweb.web.views.ibreadcrumbs import BreadCrumbEntityVComponent |
7 |
8 |
8 from cubes.tag.views import TagsBarVComponent |
9 BreadCrumbEntityVComponent.visible = True |
9 TagsBarVComponent.visible = True |
|
10 |
10 |
11 class NavigationTC(EnvBasedTC): |
11 class NavigationTC(EnvBasedTC): |
12 |
12 |
13 def test_navigation_selection(self): |
13 def test_navigation_selection(self): |
14 rset = self.execute('Any X,N WHERE X name N') |
14 rset = self.execute('Any X,N WHERE X name N') |
71 view = mock_object(is_primary=lambda x: True) |
71 view = mock_object(is_primary=lambda x: True) |
72 rset = self.execute('EUser X LIMIT 1') |
72 rset = self.execute('EUser X LIMIT 1') |
73 req = self.request() |
73 req = self.request() |
74 objs = self.vreg.possible_vobjects('contentnavigation', req, rset, |
74 objs = self.vreg.possible_vobjects('contentnavigation', req, rset, |
75 view=view, context='navtop') |
75 view=view, context='navtop') |
76 # tagbar should be in headers by default |
76 # breadcrumbs should be in headers by default |
77 clsids = set(obj.id for obj in objs) |
77 clsids = set(obj.id for obj in objs) |
78 self.failUnless('tagbar' in clsids) |
78 self.failUnless('breadcrumbs' in clsids) |
79 objs = self.vreg.possible_vobjects('contentnavigation', req, rset, |
79 objs = self.vreg.possible_vobjects('contentnavigation', req, rset, |
80 view=view, context='navbottom') |
80 view=view, context='navbottom') |
81 # tagbar should _NOT_ be in footers by default |
81 # breadcrumbs should _NOT_ be in footers by default |
82 clsids = set(obj.id for obj in objs) |
82 clsids = set(obj.id for obj in objs) |
83 self.failIf('tagbar' in clsids) |
83 self.failIf('breadcrumbs' in clsids) |
84 self.execute('INSERT EProperty P: P pkey "contentnavigation.tagbar.context", ' |
84 self.execute('INSERT EProperty P: P pkey "contentnavigation.breadcrumbs.context", ' |
85 'P value "navbottom"') |
85 'P value "navbottom"') |
86 # tagbar should now be in footers |
86 # breadcrumbs should now be in footers |
87 req.cnx.commit() |
87 req.cnx.commit() |
88 objs = self.vreg.possible_vobjects('contentnavigation', req, rset, |
88 objs = self.vreg.possible_vobjects('contentnavigation', req, rset, |
89 view=view, context='navbottom') |
89 view=view, context='navbottom') |
90 |
90 |
91 clsids = [obj.id for obj in objs] |
91 clsids = [obj.id for obj in objs] |
92 self.failUnless('tagbar' in clsids) |
92 self.failUnless('breadcrumbs' in clsids) |
93 objs = self.vreg.possible_vobjects('contentnavigation', req, rset, |
93 objs = self.vreg.possible_vobjects('contentnavigation', req, rset, |
94 view=view, context='navtop') |
94 view=view, context='navtop') |
95 |
95 |
96 clsids = [obj.id for obj in objs] |
96 clsids = [obj.id for obj in objs] |
97 self.failIf('tagbar' in clsids) |
97 self.failIf('breadcrumbs' in clsids) |
98 |
98 |
99 |
99 |
100 if __name__ == '__main__': |
100 if __name__ == '__main__': |
101 unittest_main() |
101 unittest_main() |