web/test/unittest_views_navigation.py
changeset 16 a70ece4d9d1a
parent 0 b97547f5f1fa
child 47 54087a269bdd
equal deleted inserted replaced
15:f5c9078d8168 16:a70ece4d9d1a
     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 
     7 
     8 from eclasstags.views import TagsBarVComponent
     8 from cubes.tag.views import TagsBarVComponent
     9 TagsBarVComponent.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):
    24         self.assertIsInstance(navcomp, SortedNavigation)
    24         self.assertIsInstance(navcomp, SortedNavigation)
    25         req.set_search_state('W:X:Y:Z')
    25         req.set_search_state('W:X:Y:Z')
    26         navcomp = self.vreg.select_component('navigation', req, rset)
    26         navcomp = self.vreg.select_component('navigation', req, rset)
    27         self.assertIsInstance(navcomp, SortedNavigation)
    27         self.assertIsInstance(navcomp, SortedNavigation)
    28         req.set_search_state('normal')
    28         req.set_search_state('normal')
    29         rset = self.execute('Any X,N WHERE X name N LIMIT 10')
    29         rset = self.execute('Any X,N LIMIT 10 WHERE X name N')
    30         navcomp = self.vreg.select_component('navigation', req, rset)
    30         navcomp = self.vreg.select_component('navigation', req, rset)
    31         self.assertEquals(navcomp, None)
    31         self.assertEquals(navcomp, None)
    32         req.set_search_state('W:X:Y:Z')
    32         req.set_search_state('W:X:Y:Z')
    33         navcomp = self.vreg.select_component('navigation', req, rset)
    33         navcomp = self.vreg.select_component('navigation', req, rset)
    34         self.assertEquals(navcomp, None)
    34         self.assertEquals(navcomp, None)
    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         # tagbar 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('tagsbar' in clsids)
    78         self.failUnless('tagbar' 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         # tagbar 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('tagsbar' in clsids)
    83         self.failIf('tagbar' in clsids)
    84         self.execute('INSERT EProperty P: P pkey "contentnavigation.tagsbar.context", '
    84         self.execute('INSERT EProperty P: P pkey "contentnavigation.tagbar.context", '
    85                      'P value "navbottom"')
    85                      'P value "navbottom"')
    86         # tagbar should now be in footers
    86         # tagbar 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('tagsbar' in clsids)
    92         self.failUnless('tagbar' 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('tagsbar' in clsids)
    97         self.failIf('tagbar' in clsids)
    98         
    98         
    99 
    99 
   100 if __name__ == '__main__':
   100 if __name__ == '__main__':
   101     unittest_main()
   101     unittest_main()