web/test/unittest_breadcrumbs.py
author Julien Cristau <julien.cristau@logilab.fr>
Thu, 10 Apr 2014 10:59:08 +0200
changeset 9677 f0130c270793
parent 9643 421604863753
child 9843 888a8b406124
permissions -rw-r--r--
[test] Fix regressions from 96549de9dd70 "[test] use assertIn where appropriate"
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7980
c85bea091a6c [test] fix failures introduced by 7951:b7c825b00f64
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6428
diff changeset
     1
# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
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
     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):
9643
421604863753 [web/test] port unittest_breadcrumbs to 3.19 test api
Julien Cristau <julien.cristau@logilab.fr>
parents: 7980
diff changeset
    25
        with self.admin_access.web_request() as req:
421604863753 [web/test] port unittest_breadcrumbs to 3.19 test api
Julien Cristau <julien.cristau@logilab.fr>
parents: 7980
diff changeset
    26
            f1 = req.create_entity('Folder', name=u'par&ent')
421604863753 [web/test] port unittest_breadcrumbs to 3.19 test api
Julien Cristau <julien.cristau@logilab.fr>
parents: 7980
diff changeset
    27
            f2 = req.create_entity('Folder', name=u'chi&ld')
421604863753 [web/test] port unittest_breadcrumbs to 3.19 test api
Julien Cristau <julien.cristau@logilab.fr>
parents: 7980
diff changeset
    28
            req.cnx.execute('SET F2 filed_under F1 WHERE F1 eid %(f1)s, F2 eid %(f2)s',
421604863753 [web/test] port unittest_breadcrumbs to 3.19 test api
Julien Cristau <julien.cristau@logilab.fr>
parents: 7980
diff changeset
    29
                            {'f1' : f1.eid, 'f2' : f2.eid})
421604863753 [web/test] port unittest_breadcrumbs to 3.19 test api
Julien Cristau <julien.cristau@logilab.fr>
parents: 7980
diff changeset
    30
            req.cnx.commit()
421604863753 [web/test] port unittest_breadcrumbs to 3.19 test api
Julien Cristau <julien.cristau@logilab.fr>
parents: 7980
diff changeset
    31
            self.assertEqual(f2.view('breadcrumbs'),
421604863753 [web/test] port unittest_breadcrumbs to 3.19 test api
Julien Cristau <julien.cristau@logilab.fr>
parents: 7980
diff changeset
    32
                             '<a href="http://testing.fr/cubicweb/folder/%s" title="">chi&amp;ld</a>' % f2.eid)
421604863753 [web/test] port unittest_breadcrumbs to 3.19 test api
Julien Cristau <julien.cristau@logilab.fr>
parents: 7980
diff changeset
    33
            childrset = f2.as_rset()
421604863753 [web/test] port unittest_breadcrumbs to 3.19 test api
Julien Cristau <julien.cristau@logilab.fr>
parents: 7980
diff changeset
    34
            ibc = self.vreg['ctxcomponents'].select('breadcrumbs', req, rset=childrset)
421604863753 [web/test] port unittest_breadcrumbs to 3.19 test api
Julien Cristau <julien.cristau@logilab.fr>
parents: 7980
diff changeset
    35
            l = []
421604863753 [web/test] port unittest_breadcrumbs to 3.19 test api
Julien Cristau <julien.cristau@logilab.fr>
parents: 7980
diff changeset
    36
            ibc.render(l.append)
421604863753 [web/test] port unittest_breadcrumbs to 3.19 test api
Julien Cristau <julien.cristau@logilab.fr>
parents: 7980
diff changeset
    37
            self.assertEqual(''.join(l),
421604863753 [web/test] port unittest_breadcrumbs to 3.19 test api
Julien Cristau <julien.cristau@logilab.fr>
parents: 7980
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()