author | Julien Cristau <julien.cristau@logilab.fr> |
Thu, 10 Apr 2014 10:59:08 +0200 | |
changeset 9677 | f0130c270793 |
parent 9674 | 96549de9dd70 |
child 10071 | 4bc099f2a089 |
permissions | -rw-r--r-- |
9326
9d145b4c4e53
[web] make sign_text unicode aware, avoid crash with non-ascii chars. Closes #3289774
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7791
diff
changeset
|
1 |
# -*- coding: utf-8 -*- |
9d145b4c4e53
[web] make sign_text unicode aware, avoid crash with non-ascii chars. Closes #3289774
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7791
diff
changeset
|
2 |
# copyright 2003-2013 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:
4252
diff
changeset
|
3 |
# 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:
4252
diff
changeset
|
4 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
5 |
# 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:
4252
diff
changeset
|
6 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
7 |
# 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:
4252
diff
changeset
|
8 |
# 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:
4252
diff
changeset
|
9 |
# 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:
4252
diff
changeset
|
10 |
# 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:
4252
diff
changeset
|
11 |
# |
5424
8ecbcbff9777
replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5421
diff
changeset
|
12 |
# 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:
4252
diff
changeset
|
13 |
# 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:
4252
diff
changeset
|
14 |
# 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:
4252
diff
changeset
|
15 |
# details. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
16 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
17 |
# 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:
4252
diff
changeset
|
18 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
9326
9d145b4c4e53
[web] make sign_text unicode aware, avoid crash with non-ascii chars. Closes #3289774
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7791
diff
changeset
|
19 |
"""cubicweb.web.webconfig unit tests""" |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
20 |
|
0 | 21 |
import os |
22 |
||
23 |
from logilab.common.testlib import TestCase, unittest_main |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
24 |
from cubicweb.devtools import ApptestConfiguration, fake |
0 | 25 |
|
26 |
class WebconfigTC(TestCase): |
|
27 |
def setUp(self): |
|
28 |
self.config = ApptestConfiguration('data') |
|
16
a70ece4d9d1a
fix tests in web/test
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
29 |
self.config._cubes = ['file'] |
0 | 30 |
self.config.load_configuration() |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
16
diff
changeset
|
31 |
|
0 | 32 |
def test_nonregr_print_css_as_list(self): |
33 |
"""make sure PRINT_CSS *must* is a list""" |
|
34 |
config = self.config |
|
5444
f7fdb5dd82f6
[webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
35 |
print_css = config.uiprops['STYLESHEETS_PRINT'] |
7791
31bb51ea5485
[deprecation] fix unittest pending deprecation warnings on failIf/failUnless methods family
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5907
diff
changeset
|
36 |
self.assertTrue(isinstance(print_css, list)) |
5444
f7fdb5dd82f6
[webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
37 |
ie_css = config.uiprops['STYLESHEETS_IE'] |
7791
31bb51ea5485
[deprecation] fix unittest pending deprecation warnings on failIf/failUnless methods family
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5907
diff
changeset
|
38 |
self.assertTrue(isinstance(ie_css, list)) |
0 | 39 |
|
40 |
def test_locate_resource(self): |
|
9674
96549de9dd70
[test] use assertIn where appropriate
Julien Cristau <julien.cristau@logilab.fr>
parents:
9326
diff
changeset
|
41 |
self.assertIn('FILE_ICON', self.config.uiprops) |
5444
f7fdb5dd82f6
[webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
42 |
rname = self.config.uiprops['FILE_ICON'].replace(self.config.datadir_url, '') |
9674
96549de9dd70
[test] use assertIn where appropriate
Julien Cristau <julien.cristau@logilab.fr>
parents:
9326
diff
changeset
|
43 |
self.assertIn('file', self.config.locate_resource(rname)[0].split(os.sep)) |
5907
5eba1248e12b
[web config] fix old css compat code: we have to modify locate_resource prototype so it return (potentially hacked) file name as well. Should only impact the file cube which has to be released anyway.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5444
diff
changeset
|
44 |
cubicwebcsspath = self.config.locate_resource('cubicweb.css')[0].split(os.sep) |
9677
f0130c270793
[test] Fix regressions from 96549de9dd70 "[test] use assertIn where appropriate"
Julien Cristau <julien.cristau@logilab.fr>
parents:
9674
diff
changeset
|
45 |
self.assertTrue('web' in cubicwebcsspath or 'shared' in cubicwebcsspath) # 'shared' if tests under apycot |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
16
diff
changeset
|
46 |
|
9326
9d145b4c4e53
[web] make sign_text unicode aware, avoid crash with non-ascii chars. Closes #3289774
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7791
diff
changeset
|
47 |
def test_sign_text(self): |
9d145b4c4e53
[web] make sign_text unicode aware, avoid crash with non-ascii chars. Closes #3289774
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7791
diff
changeset
|
48 |
signature = self.config.sign_text(u'hôp') |
9d145b4c4e53
[web] make sign_text unicode aware, avoid crash with non-ascii chars. Closes #3289774
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7791
diff
changeset
|
49 |
self.assertTrue(self.config.check_text_sign(u'hôp', signature)) |
9d145b4c4e53
[web] make sign_text unicode aware, avoid crash with non-ascii chars. Closes #3289774
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7791
diff
changeset
|
50 |
|
0 | 51 |
if __name__ == '__main__': |
52 |
unittest_main() |
|
53 |
||
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
16
diff
changeset
|
54 |