1 # copyright 2003-2014 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
|
2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
|
3 # |
|
4 # This file is part of CubicWeb. |
|
5 # |
|
6 # CubicWeb is free software: you can redistribute it and/or modify it under the |
|
7 # terms of the GNU Lesser General Public License as published by the Free |
|
8 # Software Foundation, either version 2.1 of the License, or (at your option) |
|
9 # any later version. |
|
10 # |
|
11 # CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
|
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
|
13 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
|
14 # details. |
|
15 # |
|
16 # You should have received a copy of the GNU Lesser General Public License along |
|
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
|
18 |
|
19 from cubicweb.devtools.testlib import CubicWebTC |
|
20 |
|
21 |
|
22 class BreadCrumbsTC(CubicWebTC): |
|
23 |
|
24 def test_base(self): |
|
25 with self.admin_access.web_request() as req: |
|
26 f1 = req.create_entity('Folder', name=u'par&ent') |
|
27 f2 = req.create_entity('Folder', name=u'chi&ld') |
|
28 req.cnx.execute('SET F2 filed_under F1 WHERE F1 eid %(f1)s, F2 eid %(f2)s', |
|
29 {'f1' : f1.eid, 'f2' : f2.eid}) |
|
30 req.cnx.commit() |
|
31 self.assertEqual(f2.view('breadcrumbs'), |
|
32 '<a href="http://testing.fr/cubicweb/folder/%s" title="">' |
|
33 'chi&ld</a>' % f2.eid) |
|
34 childrset = f2.as_rset() |
|
35 ibc = self.vreg['ctxcomponents'].select('breadcrumbs', req, rset=childrset) |
|
36 l = [] |
|
37 ibc.render(l.append) |
|
38 self.assertMultiLineEqual('<span id="breadcrumbs" class="pathbar"> > ' |
|
39 '<a href="http://testing.fr/cubicweb/Folder">Folder_plural</a>' |
|
40 ' > <a href="http://testing.fr/cubicweb/folder/%s" ' |
|
41 'title="">par&ent</a> > \n' |
|
42 '<a href="http://testing.fr/cubicweb/folder/%s" title="">' |
|
43 'chi&ld</a></span>' % (f1.eid, f2.eid), |
|
44 ''.join(l)) |
|
45 |
|
46 if __name__ == '__main__': |
|
47 from logilab.common.testlib import unittest_main |
|
48 unittest_main() |
|