web/test/unittest_breadcrumbs.py
author Alexandre Fayolle <alexandre.fayolle@logilab.fr>
Fri, 15 Apr 2011 16:05:20 +0200
changeset 7236 b91205ada414
parent 6428 de95bbed8781
child 7980 c85bea091a6c
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: 5291
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: 5291
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: 5291
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: 5291
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: 5291
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: 5291
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: 5291
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: 5291
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: 5291
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: 5291
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: 5291
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: 5291
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: 5291
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: 5291
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: 5291
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: 5291
diff changeset
    17
# with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
5569
cb14af012a96 [adapters] refactoring fixes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    18
3460
e4843535db25 [api] some more _cw / __regid__, automatic tests now pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3227
diff changeset
    19
from cubicweb.devtools.testlib import CubicWebTC
3179
0684544f6d0d from 3.5 branch; XXX the test depends on an eid value
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff changeset
    20
5569
cb14af012a96 [adapters] refactoring fixes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5424
diff changeset
    21
3460
e4843535db25 [api] some more _cw / __regid__, automatic tests now pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3227
diff changeset
    22
class BreadCrumbsTC(CubicWebTC):
3179
0684544f6d0d from 3.5 branch; XXX the test depends on an eid value
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff changeset
    23
0684544f6d0d from 3.5 branch; XXX the test depends on an eid value
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff changeset
    24
    def test_base(self):
4172
4d4cef034eec all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3460
diff changeset
    25
        req = self.request()
4d4cef034eec all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3460
diff changeset
    26
        f1 = req.create_entity('Folder', name=u'par&ent')
4d4cef034eec all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3460
diff changeset
    27
        f2 = req.create_entity('Folder', name=u'chi&ld')
3179
0684544f6d0d from 3.5 branch; XXX the test depends on an eid value
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff changeset
    28
        self.execute('SET F2 filed_under F1 WHERE F1 eid %(f1)s, F2 eid %(f2)s',
0684544f6d0d from 3.5 branch; XXX the test depends on an eid value
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff changeset
    29
                     {'f1' : f1.eid, 'f2' : f2.eid})
0684544f6d0d from 3.5 branch; XXX the test depends on an eid value
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff changeset
    30
        self.commit()
6340
470d8e828fda [test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5569
diff changeset
    31
        self.assertEqual(f2.view('breadcrumbs'),
3227
f1695b2da6c3 test fix
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3184
diff changeset
    32
                          '<a href="http://testing.fr/cubicweb/folder/%s" title="">chi&amp;ld</a>' % f2.eid)
f1695b2da6c3 test fix
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3184
diff changeset
    33
        childrset = f2.as_rset()
6428
de95bbed8781 [components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6340
diff changeset
    34
        ibc = self.vreg['ctxcomponents'].select('breadcrumbs', self.request(), rset=childrset)
de95bbed8781 [components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6340
diff changeset
    35
        l = []
de95bbed8781 [components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6340
diff changeset
    36
        ibc.render(l.append)
de95bbed8781 [components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6340
diff changeset
    37
        self.assertEqual(''.join(l),
3184
613064b49331 backport stable branch
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3176 3179
diff changeset
    38
                          """<span id="breadcrumbs" class="pathbar">&#160;&gt;&#160;<a href="http://testing.fr/cubicweb/Folder">folder_plural</a>&#160;&gt;&#160;<a href="http://testing.fr/cubicweb/folder/%s" title="">par&amp;ent</a>&#160;&gt;&#160;
5291
593adaccd737 (implement #761403) The breadcrumb final element is now a link too.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 4172
diff changeset
    39
<a href="http://testing.fr/cubicweb/folder/%s" title="">chi&amp;ld</a></span>""" % (f1.eid, f2.eid))
4172
4d4cef034eec all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3460
diff changeset
    40
4d4cef034eec all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3460
diff changeset
    41
if __name__ == '__main__':
4d4cef034eec all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3460
diff changeset
    42
    from logilab.common.testlib import unittest_main
4d4cef034eec all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3460
diff changeset
    43
    unittest_main()