author | Adrien Di Mascio <Adrien.DiMascio@logilab.fr> |
Wed, 23 Sep 2009 09:52:52 +0200 | |
changeset 3394 | 51a25bdd7bdc |
parent 1977 | 606923dff11b |
child 4212 | ab6573088b4a |
permissions | -rw-r--r-- |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
1 |
""" |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
2 |
|
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
3 |
:organization: Logilab |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
4 |
:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
5 |
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
6 |
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
7 |
""" |
0 | 8 |
|
9 |
from logilab.common.testlib import TestCase, unittest_main |
|
10 |
||
11 |
from cubicweb.web.views.embedding import prefix_links |
|
12 |
||
13 |
class UILIBTC(TestCase): |
|
14 |
||
15 |
||
16 |
def test_prefix_links(self): |
|
17 |
"""suppose we are embedding http://embedded.com/page1.html""" |
|
18 |
orig = ['<a href="http://www.perdu.com">perdu ?</a>', |
|
19 |
'<a href="http://embedded.com/page1.html">perdu ?</a>', |
|
20 |
'<a href="/page2.html">perdu ?</a>', |
|
21 |
'<a href="page3.html">perdu ?</a>', |
|
22 |
'<img src="http://www.perdu.com/img.png"/>', |
|
23 |
'<img src="/img.png"/>', |
|
24 |
'<img src="img.png"/>', |
|
25 |
] |
|
26 |
expected = ['<a href="PREFIXhttp%3A%2F%2Fwww.perdu.com">perdu ?</a>', |
|
27 |
'<a href="PREFIXhttp%3A%2F%2Fembedded.com%2Fpage1.html">perdu ?</a>', |
|
28 |
'<a href="PREFIXhttp%3A%2F%2Fembedded.com%2Fpage2.html">perdu ?</a>', |
|
29 |
'<a href="PREFIXhttp%3A%2F%2Fembedded.com%2Fpage3.html">perdu ?</a>', |
|
30 |
'<img src="http://www.perdu.com/img.png"/>', |
|
31 |
'<img src="http://embedded.com/img.png"/>', |
|
32 |
'<img src="http://embedded.com/img.png"/>', |
|
33 |
] |
|
34 |
for orig_a, expected_a in zip(orig, expected): |
|
35 |
got = prefix_links(orig_a, 'PREFIX', 'http://embedded.com/page1.html') |
|
36 |
self.assertEquals(got, expected_a) |
|
37 |
||
38 |
if __name__ == '__main__': |
|
39 |
unittest_main() |
|
40 |