author | Quentin Roquefort <roquefort.quentin@gmail.com> |
Thu, 28 Apr 2011 20:41:44 +0200 | |
changeset 7277 | acd7f0e9f276 |
parent 6415 | b0b0f097a72d |
child 7569 | 02c338197322 |
permissions | -rw-r--r-- |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5389
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:
5389
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:
5389
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:
5389
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:
5389
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:
5389
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:
5389
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:
5389
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:
5389
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:
5389
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:
5389
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:
5389
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:
5389
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:
5389
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:
5389
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:
5389
diff
changeset
|
17 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
5726
c3b99606644d
[json] fix json serialization for recent simplejson implementation, and test encoding of entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
18 |
"""unit tests for module cubicweb.utils""" |
0 | 19 |
|
4694
c19366a12281
simplejson may not be available with python 2.4
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
20 |
import re |
3231
3ee43e2f8560
[utils] provide a class to extend the default simplejson encoder to be able to dump standard yams attribute types
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2635
diff
changeset
|
21 |
import decimal |
3ee43e2f8560
[utils] provide a class to extend the default simplejson encoder to be able to dump standard yams attribute types
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2635
diff
changeset
|
22 |
import datetime |
3ee43e2f8560
[utils] provide a class to extend the default simplejson encoder to be able to dump standard yams attribute types
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2635
diff
changeset
|
23 |
|
4694
c19366a12281
simplejson may not be available with python 2.4
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
24 |
from logilab.common.testlib import TestCase, unittest_main |
7277
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
25 |
from cubicweb.devtools.testlib import CubicWebTC |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
26 |
from cubicweb.utils import make_uid, UStringIO, SizeConstrainedList, RepeatList, HTMLHead |
5726
c3b99606644d
[json] fix json serialization for recent simplejson implementation, and test encoding of entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
27 |
from cubicweb.entity import Entity |
0 | 28 |
|
4694
c19366a12281
simplejson may not be available with python 2.4
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
29 |
try: |
5389
809d3b5b3d31
[python2.6] careful: json-py provides a json package. We don't want that.
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
5377
diff
changeset
|
30 |
from cubicweb.utils import CubicWebJsonEncoder, json |
4694
c19366a12281
simplejson may not be available with python 2.4
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
31 |
except ImportError: |
5377
84d14ddfae13
[python2.6] prefer python2.6's builtin json module over simplejson
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
5077
diff
changeset
|
32 |
json = None |
0 | 33 |
|
34 |
class MakeUidTC(TestCase): |
|
35 |
def test_1(self): |
|
6415 | 36 |
self.assertNotEqual(make_uid('xyz'), make_uid('abcd')) |
37 |
self.assertNotEqual(make_uid('xyz'), make_uid('xyz')) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
720
diff
changeset
|
38 |
|
0 | 39 |
def test_2(self): |
3146
cfc4344023f2
have a better make_uid function, esp. useful for win32 as collisions are frequents with the old one
Aurelien Campeas
parents:
2635
diff
changeset
|
40 |
d = set() |
0 | 41 |
while len(d)<10000: |
42 |
uid = make_uid('xyz') |
|
3146
cfc4344023f2
have a better make_uid function, esp. useful for win32 as collisions are frequents with the old one
Aurelien Campeas
parents:
2635
diff
changeset
|
43 |
if uid in d: |
0 | 44 |
self.fail(len(d)) |
4694
c19366a12281
simplejson may not be available with python 2.4
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
45 |
if re.match('\d', uid): |
c19366a12281
simplejson may not be available with python 2.4
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
46 |
self.fail('make_uid must not return something begining with ' |
c19366a12281
simplejson may not be available with python 2.4
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
47 |
'some numeric character, got %s' % uid) |
3146
cfc4344023f2
have a better make_uid function, esp. useful for win32 as collisions are frequents with the old one
Aurelien Campeas
parents:
2635
diff
changeset
|
48 |
d.add(uid) |
0 | 49 |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
720
diff
changeset
|
50 |
|
0 | 51 |
class UStringIOTC(TestCase): |
52 |
def test_boolean_value(self): |
|
53 |
self.assert_(UStringIO()) |
|
54 |
||
55 |
||
5069
135c5d7b89d0
[querier] introduce RepeatList class, used to optimize size of data returned for result set description
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4890
diff
changeset
|
56 |
class RepeatListTC(TestCase): |
135c5d7b89d0
[querier] introduce RepeatList class, used to optimize size of data returned for result set description
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4890
diff
changeset
|
57 |
|
135c5d7b89d0
[querier] introduce RepeatList class, used to optimize size of data returned for result set description
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4890
diff
changeset
|
58 |
def test_base(self): |
135c5d7b89d0
[querier] introduce RepeatList class, used to optimize size of data returned for result set description
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4890
diff
changeset
|
59 |
l = RepeatList(3, (1, 3)) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5726
diff
changeset
|
60 |
self.assertEqual(l[0], (1, 3)) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5726
diff
changeset
|
61 |
self.assertEqual(l[2], (1, 3)) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5726
diff
changeset
|
62 |
self.assertEqual(l[-1], (1, 3)) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5726
diff
changeset
|
63 |
self.assertEqual(len(l), 3) |
5069
135c5d7b89d0
[querier] introduce RepeatList class, used to optimize size of data returned for result set description
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4890
diff
changeset
|
64 |
# XXX |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5726
diff
changeset
|
65 |
self.assertEqual(l[4], (1, 3)) |
5069
135c5d7b89d0
[querier] introduce RepeatList class, used to optimize size of data returned for result set description
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4890
diff
changeset
|
66 |
|
135c5d7b89d0
[querier] introduce RepeatList class, used to optimize size of data returned for result set description
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4890
diff
changeset
|
67 |
self.failIf(RepeatList(0, None)) |
135c5d7b89d0
[querier] introduce RepeatList class, used to optimize size of data returned for result set description
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4890
diff
changeset
|
68 |
|
135c5d7b89d0
[querier] introduce RepeatList class, used to optimize size of data returned for result set description
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4890
diff
changeset
|
69 |
def test_slice(self): |
135c5d7b89d0
[querier] introduce RepeatList class, used to optimize size of data returned for result set description
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4890
diff
changeset
|
70 |
l = RepeatList(3, (1, 3)) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5726
diff
changeset
|
71 |
self.assertEqual(l[0:1], [(1, 3)]) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5726
diff
changeset
|
72 |
self.assertEqual(l[0:4], [(1, 3)]*3) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5726
diff
changeset
|
73 |
self.assertEqual(l[:], [(1, 3)]*3) |
5069
135c5d7b89d0
[querier] introduce RepeatList class, used to optimize size of data returned for result set description
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4890
diff
changeset
|
74 |
|
135c5d7b89d0
[querier] introduce RepeatList class, used to optimize size of data returned for result set description
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4890
diff
changeset
|
75 |
def test_iter(self): |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5726
diff
changeset
|
76 |
self.assertEqual(list(RepeatList(3, (1, 3))), |
5069
135c5d7b89d0
[querier] introduce RepeatList class, used to optimize size of data returned for result set description
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4890
diff
changeset
|
77 |
[(1, 3)]*3) |
135c5d7b89d0
[querier] introduce RepeatList class, used to optimize size of data returned for result set description
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4890
diff
changeset
|
78 |
|
135c5d7b89d0
[querier] introduce RepeatList class, used to optimize size of data returned for result set description
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4890
diff
changeset
|
79 |
def test_add(self): |
135c5d7b89d0
[querier] introduce RepeatList class, used to optimize size of data returned for result set description
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4890
diff
changeset
|
80 |
l = RepeatList(3, (1, 3)) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5726
diff
changeset
|
81 |
self.assertEqual(l + [(1, 4)], [(1, 3)]*3 + [(1, 4)]) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5726
diff
changeset
|
82 |
self.assertEqual([(1, 4)] + l, [(1, 4)] + [(1, 3)]*3) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5726
diff
changeset
|
83 |
self.assertEqual(l + RepeatList(2, (2, 3)), [(1, 3)]*3 + [(2, 3)]*2) |
5069
135c5d7b89d0
[querier] introduce RepeatList class, used to optimize size of data returned for result set description
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4890
diff
changeset
|
84 |
|
135c5d7b89d0
[querier] introduce RepeatList class, used to optimize size of data returned for result set description
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4890
diff
changeset
|
85 |
x = l + RepeatList(2, (1, 3)) |
135c5d7b89d0
[querier] introduce RepeatList class, used to optimize size of data returned for result set description
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4890
diff
changeset
|
86 |
self.assertIsInstance(x, RepeatList) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5726
diff
changeset
|
87 |
self.assertEqual(len(x), 5) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5726
diff
changeset
|
88 |
self.assertEqual(x[0], (1, 3)) |
5069
135c5d7b89d0
[querier] introduce RepeatList class, used to optimize size of data returned for result set description
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4890
diff
changeset
|
89 |
|
135c5d7b89d0
[querier] introduce RepeatList class, used to optimize size of data returned for result set description
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4890
diff
changeset
|
90 |
x = l + [(1, 3)] * 2 |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5726
diff
changeset
|
91 |
self.assertEqual(x, [(1, 3)] * 5) |
5069
135c5d7b89d0
[querier] introduce RepeatList class, used to optimize size of data returned for result set description
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4890
diff
changeset
|
92 |
|
5077
dc448c9ad9dd
[rset] cubes such as iliane hi-jack rset description by poping some lines from it. Handle this on RepeatList
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5069
diff
changeset
|
93 |
def test_eq(self): |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5726
diff
changeset
|
94 |
self.assertEqual(RepeatList(3, (1, 3)), |
5077
dc448c9ad9dd
[rset] cubes such as iliane hi-jack rset description by poping some lines from it. Handle this on RepeatList
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5069
diff
changeset
|
95 |
[(1, 3)]*3) |
dc448c9ad9dd
[rset] cubes such as iliane hi-jack rset description by poping some lines from it. Handle this on RepeatList
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5069
diff
changeset
|
96 |
|
dc448c9ad9dd
[rset] cubes such as iliane hi-jack rset description by poping some lines from it. Handle this on RepeatList
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5069
diff
changeset
|
97 |
def test_pop(self): |
dc448c9ad9dd
[rset] cubes such as iliane hi-jack rset description by poping some lines from it. Handle this on RepeatList
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5069
diff
changeset
|
98 |
l = RepeatList(3, (1, 3)) |
dc448c9ad9dd
[rset] cubes such as iliane hi-jack rset description by poping some lines from it. Handle this on RepeatList
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5069
diff
changeset
|
99 |
l.pop(2) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5726
diff
changeset
|
100 |
self.assertEqual(l, [(1, 3)]*2) |
5069
135c5d7b89d0
[querier] introduce RepeatList class, used to optimize size of data returned for result set description
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4890
diff
changeset
|
101 |
|
5726
c3b99606644d
[json] fix json serialization for recent simplejson implementation, and test encoding of entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
102 |
|
0 | 103 |
class SizeConstrainedListTC(TestCase): |
104 |
||
105 |
def test_append(self): |
|
106 |
l = SizeConstrainedList(10) |
|
107 |
for i in xrange(12): |
|
108 |
l.append(i) |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5726
diff
changeset
|
109 |
self.assertEqual(l, range(2, 12)) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
720
diff
changeset
|
110 |
|
0 | 111 |
def test_extend(self): |
112 |
testdata = [(range(5), range(5)), |
|
113 |
(range(10), range(10)), |
|
114 |
(range(12), range(2, 12)), |
|
115 |
] |
|
116 |
for extension, expected in testdata: |
|
117 |
l = SizeConstrainedList(10) |
|
118 |
l.extend(extension) |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5726
diff
changeset
|
119 |
yield self.assertEqual, l, expected |
0 | 120 |
|
5726
c3b99606644d
[json] fix json serialization for recent simplejson implementation, and test encoding of entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
121 |
|
4890 | 122 |
class JSONEncoderTC(TestCase): |
4694
c19366a12281
simplejson may not be available with python 2.4
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
123 |
def setUp(self): |
5377
84d14ddfae13
[python2.6] prefer python2.6's builtin json module over simplejson
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
5077
diff
changeset
|
124 |
if json is None: |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5726
diff
changeset
|
125 |
self.skipTest('json not available') |
3231
3ee43e2f8560
[utils] provide a class to extend the default simplejson encoder to be able to dump standard yams attribute types
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2635
diff
changeset
|
126 |
|
3ee43e2f8560
[utils] provide a class to extend the default simplejson encoder to be able to dump standard yams attribute types
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2635
diff
changeset
|
127 |
def encode(self, value): |
5377
84d14ddfae13
[python2.6] prefer python2.6's builtin json module over simplejson
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
5077
diff
changeset
|
128 |
return json.dumps(value, cls=CubicWebJsonEncoder) |
3231
3ee43e2f8560
[utils] provide a class to extend the default simplejson encoder to be able to dump standard yams attribute types
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2635
diff
changeset
|
129 |
|
3ee43e2f8560
[utils] provide a class to extend the default simplejson encoder to be able to dump standard yams attribute types
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2635
diff
changeset
|
130 |
def test_encoding_dates(self): |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5726
diff
changeset
|
131 |
self.assertEqual(self.encode(datetime.datetime(2009, 9, 9, 20, 30)), |
3231
3ee43e2f8560
[utils] provide a class to extend the default simplejson encoder to be able to dump standard yams attribute types
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2635
diff
changeset
|
132 |
'"2009/09/09 20:30:00"') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5726
diff
changeset
|
133 |
self.assertEqual(self.encode(datetime.date(2009, 9, 9)), |
3231
3ee43e2f8560
[utils] provide a class to extend the default simplejson encoder to be able to dump standard yams attribute types
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2635
diff
changeset
|
134 |
'"2009/09/09"') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5726
diff
changeset
|
135 |
self.assertEqual(self.encode(datetime.time(20, 30)), |
3231
3ee43e2f8560
[utils] provide a class to extend the default simplejson encoder to be able to dump standard yams attribute types
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2635
diff
changeset
|
136 |
'"20:30:00"') |
3ee43e2f8560
[utils] provide a class to extend the default simplejson encoder to be able to dump standard yams attribute types
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2635
diff
changeset
|
137 |
|
3ee43e2f8560
[utils] provide a class to extend the default simplejson encoder to be able to dump standard yams attribute types
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2635
diff
changeset
|
138 |
def test_encoding_decimal(self): |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5726
diff
changeset
|
139 |
self.assertEqual(self.encode(decimal.Decimal('1.2')), '1.2') |
3231
3ee43e2f8560
[utils] provide a class to extend the default simplejson encoder to be able to dump standard yams attribute types
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2635
diff
changeset
|
140 |
|
5726
c3b99606644d
[json] fix json serialization for recent simplejson implementation, and test encoding of entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
141 |
def test_encoding_bare_entity(self): |
c3b99606644d
[json] fix json serialization for recent simplejson implementation, and test encoding of entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
142 |
e = Entity(None) |
6142
8bc6eac1fac1
[session] cleanup hook / operation / entity edition api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5726
diff
changeset
|
143 |
e.cw_attr_cache['pouet'] = 'hop' |
5726
c3b99606644d
[json] fix json serialization for recent simplejson implementation, and test encoding of entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
144 |
e.eid = 2 |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5726
diff
changeset
|
145 |
self.assertEqual(json.loads(self.encode(e)), |
5726
c3b99606644d
[json] fix json serialization for recent simplejson implementation, and test encoding of entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
146 |
{'pouet': 'hop', 'eid': 2}) |
c3b99606644d
[json] fix json serialization for recent simplejson implementation, and test encoding of entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
147 |
|
c3b99606644d
[json] fix json serialization for recent simplejson implementation, and test encoding of entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
148 |
def test_encoding_entity_in_list(self): |
c3b99606644d
[json] fix json serialization for recent simplejson implementation, and test encoding of entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
149 |
e = Entity(None) |
6142
8bc6eac1fac1
[session] cleanup hook / operation / entity edition api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5726
diff
changeset
|
150 |
e.cw_attr_cache['pouet'] = 'hop' |
5726
c3b99606644d
[json] fix json serialization for recent simplejson implementation, and test encoding of entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
151 |
e.eid = 2 |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5726
diff
changeset
|
152 |
self.assertEqual(json.loads(self.encode([e])), |
5726
c3b99606644d
[json] fix json serialization for recent simplejson implementation, and test encoding of entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
153 |
[{'pouet': 'hop', 'eid': 2}]) |
c3b99606644d
[json] fix json serialization for recent simplejson implementation, and test encoding of entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
154 |
|
3231
3ee43e2f8560
[utils] provide a class to extend the default simplejson encoder to be able to dump standard yams attribute types
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2635
diff
changeset
|
155 |
def test_encoding_unknown_stuff(self): |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5726
diff
changeset
|
156 |
self.assertEqual(self.encode(TestCase), 'null') |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
720
diff
changeset
|
157 |
|
7277
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
158 |
class HTMLHeadTC(CubicWebTC): |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
159 |
def test_concat_urls(self): |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
160 |
base_url = u'http://test.fr/data/' |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
161 |
head = HTMLHead(base_url) |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
162 |
urls = [base_url + u'bob1.js', |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
163 |
base_url + u'bob2.js', |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
164 |
base_url + u'bob3.js'] |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
165 |
result = head.concat_urls(urls) |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
166 |
expected = u'http://test.fr/data/??bob1.js,bob2.js,bob3.js' |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
167 |
self.assertEqual(result, expected) |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
168 |
|
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
169 |
def test_group_urls(self): |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
170 |
base_url = u'http://test.fr/data/' |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
171 |
head = HTMLHead(base_url) |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
172 |
urls_spec = [(base_url + u'bob0.js', None), |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
173 |
(base_url + u'bob1.js', None), |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
174 |
(u'http://ext.com/bob2.js', None), |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
175 |
(u'http://ext.com/bob3.js', None), |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
176 |
(base_url + u'bob4.css', 'all'), |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
177 |
(base_url + u'bob5.css', 'all'), |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
178 |
(base_url + u'bob6.css', 'print'), |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
179 |
(base_url + u'bob7.css', 'print'), |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
180 |
(base_url + u'bob8.css', ('all', u'[if IE 8]')), |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
181 |
(base_url + u'bob9.css', ('print', u'[if IE 8]')) |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
182 |
] |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
183 |
result = head.group_urls(urls_spec) |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
184 |
expected = [(base_url + u'??bob0.js,bob1.js', None), |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
185 |
(u'http://ext.com/bob2.js', None), |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
186 |
(u'http://ext.com/bob3.js', None), |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
187 |
(base_url + u'??bob4.css,bob5.css', 'all'), |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
188 |
(base_url + u'??bob6.css,bob7.css', 'print'), |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
189 |
(base_url + u'bob8.css', ('all', u'[if IE 8]')), |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
190 |
(base_url + u'bob9.css', ('print', u'[if IE 8]')) |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
191 |
] |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
192 |
self.assertEqual(list(result), expected) |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
193 |
|
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
194 |
def test_getvalue_with_concat(self): |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
195 |
base_url = u'http://test.fr/data/' |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
196 |
head = HTMLHead(base_url) |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
197 |
head.add_js(base_url + u'bob0.js') |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
198 |
head.add_js(base_url + u'bob1.js') |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
199 |
head.add_js(u'http://ext.com/bob2.js') |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
200 |
head.add_js(u'http://ext.com/bob3.js') |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
201 |
head.add_css(base_url + u'bob4.css') |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
202 |
head.add_css(base_url + u'bob5.css') |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
203 |
head.add_css(base_url + u'bob6.css', 'print') |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
204 |
head.add_css(base_url + u'bob7.css', 'print') |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
205 |
head.add_ie_css(base_url + u'bob8.css') |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
206 |
head.add_ie_css(base_url + u'bob9.css', 'print', u'[if lt IE 7]') |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
207 |
result = head.getvalue() |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
208 |
expected = u"""<head> |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
209 |
<link rel="stylesheet" type="text/css" media="all" href="http://test.fr/data/??bob4.css,bob5.css"/> |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
210 |
<link rel="stylesheet" type="text/css" media="print" href="http://test.fr/data/??bob6.css,bob7.css"/> |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
211 |
<!--[if lt IE 8]> |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
212 |
<link rel="stylesheet" type="text/css" media="all" href="http://test.fr/data/bob8.css"/> |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
213 |
<!--[if lt IE 7]> |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
214 |
<link rel="stylesheet" type="text/css" media="print" href="http://test.fr/data/bob9.css"/> |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
215 |
<![endif]--> |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
216 |
<script type="text/javascript" src="http://test.fr/data/??bob0.js,bob1.js"></script> |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
217 |
<script type="text/javascript" src="http://ext.com/bob2.js"></script> |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
218 |
<script type="text/javascript" src="http://ext.com/bob3.js"></script> |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
219 |
</head> |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
220 |
""" |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
221 |
self.assertEqual(result, expected) |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
222 |
|
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
223 |
def test_getvalue_without_concat(self): |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
224 |
base_url = u'http://test.fr/data/' |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
225 |
head = HTMLHead() |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
226 |
head.add_js(base_url + u'bob0.js') |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
227 |
head.add_js(base_url + u'bob1.js') |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
228 |
head.add_js(u'http://ext.com/bob2.js') |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
229 |
head.add_js(u'http://ext.com/bob3.js') |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
230 |
head.add_css(base_url + u'bob4.css') |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
231 |
head.add_css(base_url + u'bob5.css') |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
232 |
head.add_css(base_url + u'bob6.css', 'print') |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
233 |
head.add_css(base_url + u'bob7.css', 'print') |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
234 |
head.add_ie_css(base_url + u'bob8.css') |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
235 |
head.add_ie_css(base_url + u'bob9.css', 'print', u'[if lt IE 7]') |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
236 |
result = head.getvalue() |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
237 |
expected = u"""<head> |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
238 |
<link rel="stylesheet" type="text/css" media="all" href="http://test.fr/data/bob4.css"/> |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
239 |
<link rel="stylesheet" type="text/css" media="all" href="http://test.fr/data/bob5.css"/> |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
240 |
<link rel="stylesheet" type="text/css" media="print" href="http://test.fr/data/bob6.css"/> |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
241 |
<link rel="stylesheet" type="text/css" media="print" href="http://test.fr/data/bob7.css"/> |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
242 |
<!--[if lt IE 8]> |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
243 |
<link rel="stylesheet" type="text/css" media="all" href="http://test.fr/data/bob8.css"/> |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
244 |
<!--[if lt IE 7]> |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
245 |
<link rel="stylesheet" type="text/css" media="print" href="http://test.fr/data/bob9.css"/> |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
246 |
<![endif]--> |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
247 |
<script type="text/javascript" src="http://test.fr/data/bob0.js"></script> |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
248 |
<script type="text/javascript" src="http://test.fr/data/bob1.js"></script> |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
249 |
<script type="text/javascript" src="http://ext.com/bob2.js"></script> |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
250 |
<script type="text/javascript" src="http://ext.com/bob3.js"></script> |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
251 |
</head> |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
252 |
""" |
acd7f0e9f276
[etwist] Generates apache's mod_concat-like urls for js and css
Quentin Roquefort <roquefort.quentin@gmail.com>
parents:
6415
diff
changeset
|
253 |
self.assertEqual(result, expected) |
4890 | 254 |
|
0 | 255 |
if __name__ == '__main__': |
256 |
unittest_main() |