1 # -*- coding: utf-8 -*- |
|
2 # copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
|
3 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
|
4 # |
|
5 # This file is part of CubicWeb. |
|
6 # |
|
7 # CubicWeb is free software: you can redistribute it and/or modify it under the |
|
8 # terms of the GNU Lesser General Public License as published by the Free |
|
9 # Software Foundation, either version 2.1 of the License, or (at your option) |
|
10 # any later version. |
|
11 # |
|
12 # CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
|
13 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
|
14 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
|
15 # details. |
|
16 # |
|
17 # You should have received a copy of the GNU Lesser General Public License along |
|
18 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
|
19 """cubicweb.web.webconfig unit tests""" |
|
20 |
|
21 import os |
|
22 |
|
23 from logilab.common.testlib import TestCase, unittest_main |
|
24 from cubicweb.devtools import ApptestConfiguration, fake |
|
25 |
|
26 class WebconfigTC(TestCase): |
|
27 def setUp(self): |
|
28 # need explicit None if dirname(__file__) is empty, see |
|
29 # ApptestConfiguration.__init__ |
|
30 self.config = ApptestConfiguration('data', apphome=os.path.dirname(__file__) or None) |
|
31 self.config._cubes = ['file'] |
|
32 self.config.load_configuration() |
|
33 |
|
34 def test_nonregr_print_css_as_list(self): |
|
35 """make sure PRINT_CSS *must* is a list""" |
|
36 config = self.config |
|
37 print_css = config.uiprops['STYLESHEETS_PRINT'] |
|
38 self.assertTrue(isinstance(print_css, list)) |
|
39 ie_css = config.uiprops['STYLESHEETS_IE'] |
|
40 self.assertTrue(isinstance(ie_css, list)) |
|
41 |
|
42 def test_locate_resource(self): |
|
43 self.assertIn('FILE_ICON', self.config.uiprops) |
|
44 rname = self.config.uiprops['FILE_ICON'].replace(self.config.datadir_url, '') |
|
45 self.assertIn('file', self.config.locate_resource(rname)[0].split(os.sep)) |
|
46 cubicwebcsspath = self.config.locate_resource('cubicweb.css')[0].split(os.sep) |
|
47 |
|
48 # 'shared' if tests under apycot |
|
49 self.assertTrue('web' in cubicwebcsspath or 'shared' in cubicwebcsspath, |
|
50 'neither "web" nor "shared" found in cubicwebcsspath (%s)' |
|
51 % cubicwebcsspath) |
|
52 |
|
53 def test_sign_text(self): |
|
54 signature = self.config.sign_text(u'hôp') |
|
55 self.assertTrue(self.config.check_text_sign(u'hôp', signature)) |
|
56 |
|
57 if __name__ == '__main__': |
|
58 unittest_main() |
|