author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Wed, 24 Jul 2013 16:55:24 +0200 | |
branch | stable |
changeset 9188 | 0677e03077fb |
parent 8801 | 86c1a5afbe4e |
child 9675 | 8aabfefc8a81 |
permissions | -rw-r--r-- |
8190
2a3c1b787688
[vreg] move base registry implementation to logilab.common. Closes #1916014
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7791
diff
changeset
|
1 |
# copyright 2003-2012 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:
4491
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:
4491
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:
4491
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:
4491
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:
4491
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:
4491
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:
4491
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:
4491
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:
4491
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:
4491
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:
4491
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:
4491
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:
4491
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:
4491
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:
4491
diff
changeset
|
17 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1787
diff
changeset
|
18 |
|
0 | 19 |
from logilab.common.testlib import unittest_main, TestCase |
20 |
||
21 |
from os.path import join |
|
22 |
||
23 |
from cubicweb import CW_SOFTWARE_ROOT as BASE |
|
2657
de974465d381
[appobject] kill VObject class, move base selector classes to appobject
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2650
diff
changeset
|
24 |
from cubicweb.appobject import AppObject |
8190
2a3c1b787688
[vreg] move base registry implementation to logilab.common. Closes #1916014
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7791
diff
changeset
|
25 |
from cubicweb.cwvreg import CWRegistryStore, UnknownProperty |
777
39695e98ba35
test and fix interface based objects cleaning
sylvain.thenault@logilab.fr
parents:
750
diff
changeset
|
26 |
from cubicweb.devtools import TestServerConfiguration |
4490
d45cde54d464
backport stable branch and some vreg cleanups:
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
27 |
from cubicweb.devtools.testlib import CubicWebTC |
5724
a39ecb0e6d99
[test] fix test broken by 5721:61d6a4caa963, and update it to proper adapters to avoid deprecation warning
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5466
diff
changeset
|
28 |
from cubicweb.view import EntityAdapter |
0 | 29 |
|
1640 | 30 |
from cubes.card.entities import Card |
31 |
||
0 | 32 |
class YesSchema: |
33 |
def __contains__(self, something): |
|
34 |
return True |
|
1341 | 35 |
|
36 |
WEBVIEWSDIR = join(BASE, 'web', 'views') |
|
1640 | 37 |
|
0 | 38 |
class VRegistryTC(TestCase): |
39 |
||
40 |
def setUp(self): |
|
777
39695e98ba35
test and fix interface based objects cleaning
sylvain.thenault@logilab.fr
parents:
750
diff
changeset
|
41 |
config = TestServerConfiguration('data') |
8190
2a3c1b787688
[vreg] move base registry implementation to logilab.common. Closes #1916014
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7791
diff
changeset
|
42 |
self.vreg = CWRegistryStore(config) |
777
39695e98ba35
test and fix interface based objects cleaning
sylvain.thenault@logilab.fr
parents:
750
diff
changeset
|
43 |
config.bootstrap_cubes() |
39695e98ba35
test and fix interface based objects cleaning
sylvain.thenault@logilab.fr
parents:
750
diff
changeset
|
44 |
self.vreg.schema = config.load_schema() |
1640 | 45 |
|
0 | 46 |
def test_load_interface_based_vojects(self): |
1341 | 47 |
self.vreg.init_registration([WEBVIEWSDIR]) |
1640 | 48 |
self.vreg.load_file(join(BASE, 'entities', '__init__.py'), 'cubicweb.entities.__init__') |
1341 | 49 |
self.vreg.load_file(join(WEBVIEWSDIR, 'idownloadable.py'), 'cubicweb.web.views.idownloadable') |
1640 | 50 |
self.vreg.load_file(join(WEBVIEWSDIR, 'primary.py'), 'cubicweb.web.views.primary') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5724
diff
changeset
|
51 |
self.assertEqual(len(self.vreg['views']['primary']), 2) |
1640 | 52 |
self.vreg.initialization_completed() |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5724
diff
changeset
|
53 |
self.assertEqual(len(self.vreg['views']['primary']), 1) |
1640 | 54 |
|
777
39695e98ba35
test and fix interface based objects cleaning
sylvain.thenault@logilab.fr
parents:
750
diff
changeset
|
55 |
|
2657
de974465d381
[appobject] kill VObject class, move base selector classes to appobject
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2650
diff
changeset
|
56 |
def test_load_subinterface_based_appobjects(self): |
8801
86c1a5afbe4e
Drop iprogress code (closes #2777628)
Rémi Cardona <remi.cardona@logilab.fr>
parents:
8190
diff
changeset
|
57 |
self.vreg.register_objects([join(BASE, 'web', 'views', 'idownloadable.py')]) |
86c1a5afbe4e
Drop iprogress code (closes #2777628)
Rémi Cardona <remi.cardona@logilab.fr>
parents:
8190
diff
changeset
|
58 |
# check downloadlink was kicked |
86c1a5afbe4e
Drop iprogress code (closes #2777628)
Rémi Cardona <remi.cardona@logilab.fr>
parents:
8190
diff
changeset
|
59 |
self.assertFalse(self.vreg['views'].get('downloadlink')) |
5466
b5af2ac0c43c
[uiprops] test and fix reloading of modified css files; update c-c newcube; deprecates config.has_resource.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
60 |
# we've to emulate register_objects to add custom MyCard objects |
b5af2ac0c43c
[uiprops] test and fix reloading of modified css files; update c-c newcube; deprecates config.has_resource.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
61 |
path = [join(BASE, 'entities', '__init__.py'), |
5724
a39ecb0e6d99
[test] fix test broken by 5721:61d6a4caa963, and update it to proper adapters to avoid deprecation warning
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5466
diff
changeset
|
62 |
join(BASE, 'entities', 'adapters.py'), |
8801
86c1a5afbe4e
Drop iprogress code (closes #2777628)
Rémi Cardona <remi.cardona@logilab.fr>
parents:
8190
diff
changeset
|
63 |
join(BASE, 'web', 'views', 'idownloadable.py')] |
5466
b5af2ac0c43c
[uiprops] test and fix reloading of modified css files; update c-c newcube; deprecates config.has_resource.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
64 |
filemods = self.vreg.init_registration(path, None) |
b5af2ac0c43c
[uiprops] test and fix reloading of modified css files; update c-c newcube; deprecates config.has_resource.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
65 |
for filepath, modname in filemods: |
b5af2ac0c43c
[uiprops] test and fix reloading of modified css files; update c-c newcube; deprecates config.has_resource.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
66 |
self.vreg.load_file(filepath, modname) |
8801
86c1a5afbe4e
Drop iprogress code (closes #2777628)
Rémi Cardona <remi.cardona@logilab.fr>
parents:
8190
diff
changeset
|
67 |
class CardIDownloadableAdapter(EntityAdapter): |
86c1a5afbe4e
Drop iprogress code (closes #2777628)
Rémi Cardona <remi.cardona@logilab.fr>
parents:
8190
diff
changeset
|
68 |
__regid__ = 'IDownloadable' |
1341 | 69 |
self.vreg._loadedmods[__name__] = {} |
8801
86c1a5afbe4e
Drop iprogress code (closes #2777628)
Rémi Cardona <remi.cardona@logilab.fr>
parents:
8190
diff
changeset
|
70 |
self.vreg.register(CardIDownloadableAdapter) |
5466
b5af2ac0c43c
[uiprops] test and fix reloading of modified css files; update c-c newcube; deprecates config.has_resource.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
71 |
self.vreg.initialization_completed() |
777
39695e98ba35
test and fix interface based objects cleaning
sylvain.thenault@logilab.fr
parents:
750
diff
changeset
|
72 |
# check progressbar isn't kicked |
8801
86c1a5afbe4e
Drop iprogress code (closes #2777628)
Rémi Cardona <remi.cardona@logilab.fr>
parents:
8190
diff
changeset
|
73 |
self.assertEqual(len(self.vreg['views']['downloadlink']), 1) |
1640 | 74 |
|
4485
5f99eb0b99f7
initialize property once initialization has been fully completed, close #666573
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
75 |
def test_properties(self): |
5466
b5af2ac0c43c
[uiprops] test and fix reloading of modified css files; update c-c newcube; deprecates config.has_resource.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
76 |
self.vreg.reset() |
7791
31bb51ea5485
[deprecation] fix unittest pending deprecation warnings on failIf/failUnless methods family
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
77 |
self.assertFalse('system.version.cubicweb' in self.vreg['propertydefs']) |
31bb51ea5485
[deprecation] fix unittest pending deprecation warnings on failIf/failUnless methods family
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
78 |
self.assertTrue(self.vreg.property_info('system.version.cubicweb')) |
4485
5f99eb0b99f7
initialize property once initialization has been fully completed, close #666573
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
79 |
self.assertRaises(UnknownProperty, self.vreg.property_info, 'a.non.existent.key') |
5f99eb0b99f7
initialize property once initialization has been fully completed, close #666573
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
80 |
|
4490
d45cde54d464
backport stable branch and some vreg cleanups:
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
81 |
|
d45cde54d464
backport stable branch and some vreg cleanups:
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
82 |
class CWVregTC(CubicWebTC): |
4485
5f99eb0b99f7
initialize property once initialization has been fully completed, close #666573
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
83 |
|
5f99eb0b99f7
initialize property once initialization has been fully completed, close #666573
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
84 |
def test_property_default_overriding(self): |
5f99eb0b99f7
initialize property once initialization has been fully completed, close #666573
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
85 |
# see data/views.py |
5f99eb0b99f7
initialize property once initialization has been fully completed, close #666573
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
86 |
from cubicweb.web.views.xmlrss import RSSIconBox |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5724
diff
changeset
|
87 |
self.assertEqual(self.vreg.property_info(RSSIconBox._cwpropkey('visible'))['default'], True) |
0 | 88 |
|
89 |
if __name__ == '__main__': |
|
90 |
unittest_main() |