web/test/unittest_views_navigation.py
author Alexandre Fayolle <alexandre.fayolle@logilab.fr>
Fri, 15 Apr 2011 16:05:20 +0200
changeset 7236 b91205ada414
parent 7000 09e32d10e6bc
child 7791 31bb51ea5485
permissions -rw-r--r--
added test case to monitor speed improvements in the repository code. To use it, add a test in a patch, then hack CW to speed it up in another patch, updating the test if needed. By running the test with and without the second patch applied you can easily see the speed improvements
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    19
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    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
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    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
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    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
30c3a713ab61 View.dispatch -> View.render
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    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
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    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
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    35
        self.assertIsInstance(navcomp, PageNavigation)
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    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
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    38
        self.assertIsInstance(navcomp, PageNavigation)
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    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
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    45
        self.assertIsInstance(navcomp, SortedNavigation)
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    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
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    48
        self.assertIsInstance(navcomp, SortedNavigation)
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    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
7000
09e32d10e6bc [web test] fix test name conflict
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6366
diff changeset
    61
    def test_navigation_selection_not_enough_1(self):
2676
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)
6340
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5623
diff changeset
    65
        self.assertEqual(navcomp, None)
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    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)
6340
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5623
diff changeset
    68
        self.assertEqual(navcomp, None)
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    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
7000
09e32d10e6bc [web test] fix test name conflict
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6366
diff changeset
    71
    def test_navigation_selection_not_enough_2(self):
2676
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
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    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
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    75
        self.assertIsInstance(navcomp, SortedNavigation)
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    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
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    78
        self.assertIsInstance(navcomp, SortedNavigation)
1723
30c3a713ab61 View.dispatch -> View.render
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    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
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    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
30c3a713ab61 View.dispatch -> View.render
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    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
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    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
30c3a713ab61 View.dispatch -> View.render
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    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
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    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
30c3a713ab61 View.dispatch -> View.render
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    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
30c3a713ab61 View.dispatch -> View.render
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   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
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   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
30c3a713ab61 View.dispatch -> View.render
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   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
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   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
30c3a713ab61 View.dispatch -> View.render
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   116
        html = navcomp.render()
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   117
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   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
1d25e928c299 backport 3.5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2813 3224
diff changeset
   120
# class ContentNavigationTC(CubicWebTC):
1d25e928c299 backport 3.5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2813 3224
diff changeset
   121
    # def test_component_context(self):
1d25e928c299 backport 3.5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2813 3224
diff changeset
   122
    #     view = mock_object(is_primary=lambda x: True)
1d25e928c299 backport 3.5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2813 3224
diff changeset
   123
    #     rset = self.execute('CWUser X LIMIT 1')
1d25e928c299 backport 3.5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2813 3224
diff changeset
   124
    #     req = self.request()
6141
b8287e54b528 [web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5623
diff changeset
   125
    #     objs = self.vreg['ctxcomponents'].poss_visible_objects(
3230
1d25e928c299 backport 3.5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2813 3224
diff changeset
   126
    #         req, rset=rset, view=view, context='navtop')
1d25e928c299 backport 3.5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2813 3224
diff changeset
   127
    #     # breadcrumbs should be in headers by default
1d25e928c299 backport 3.5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2813 3224
diff changeset
   128
    #     clsids = set(obj.id for obj in objs)
1d25e928c299 backport 3.5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2813 3224
diff changeset
   129
    #     self.failUnless('breadcrumbs' in clsids)
6141
b8287e54b528 [web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5623
diff changeset
   130
    #     objs = self.vreg['ctxcomponents'].poss_visible_objects(
3230
1d25e928c299 backport 3.5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2813 3224
diff changeset
   131
    #         req, rset=rset, view=view, context='navbottom')
1d25e928c299 backport 3.5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2813 3224
diff changeset
   132
    #     # breadcrumbs should _NOT_ be in footers by default
1d25e928c299 backport 3.5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2813 3224
diff changeset
   133
    #     clsids = set(obj.id for obj in objs)
1d25e928c299 backport 3.5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2813 3224
diff changeset
   134
    #     self.failIf('breadcrumbs' in clsids)
6141
b8287e54b528 [web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5623
diff changeset
   135
    #     self.execute('INSERT CWProperty P: P pkey "ctxcomponents.breadcrumbs.context", '
3230
1d25e928c299 backport 3.5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2813 3224
diff changeset
   136
    #                  'P value "navbottom"')
1d25e928c299 backport 3.5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2813 3224
diff changeset
   137
    #     # breadcrumbs should now be in footers
1d25e928c299 backport 3.5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2813 3224
diff changeset
   138
    #     req.cnx.commit()
6141
b8287e54b528 [web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5623
diff changeset
   139
    #     objs = self.vreg['ctxcomponents'].poss_visible_objects(
3230
1d25e928c299 backport 3.5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2813 3224
diff changeset
   140
    #         req, rset=rset, view=view, context='navbottom')
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   141
3230
1d25e928c299 backport 3.5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2813 3224
diff changeset
   142
    #     clsids = [obj.id for obj in objs]
1d25e928c299 backport 3.5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2813 3224
diff changeset
   143
    #     self.failUnless('breadcrumbs' in clsids)
6141
b8287e54b528 [web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5623
diff changeset
   144
    #     objs = self.vreg['ctxcomponents'].poss_visible_objects(
3230
1d25e928c299 backport 3.5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2813 3224
diff changeset
   145
    #         req, rset=rset, view=view, context='navtop')
1723
30c3a713ab61 View.dispatch -> View.render
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   146
3230
1d25e928c299 backport 3.5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2813 3224
diff changeset
   147
    #     clsids = [obj.id for obj in objs]
1d25e928c299 backport 3.5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2813 3224
diff changeset
   148
    #     self.failIf('breadcrumbs' in clsids)
1723
30c3a713ab61 View.dispatch -> View.render
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   149
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   150
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   151
if __name__ == '__main__':
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   152
    unittest_main()