author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Tue, 16 Mar 2010 17:56:04 +0100 | |
changeset 4919 | d8523d485c69 |
parent 4491 | a0f48c31b58a |
child 5421 | 8167de96c523 |
permissions | -rw-r--r-- |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1787
diff
changeset
|
1 |
""" |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1787
diff
changeset
|
2 |
|
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1787
diff
changeset
|
3 |
:organization: Logilab |
4212
ab6573088b4a
update copyright: welcome 2010
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2657
diff
changeset
|
4 |
:copyright: 2001-2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1787
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:
1787
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:
1787
diff
changeset
|
7 |
""" |
0 | 8 |
from logilab.common.testlib import unittest_main, TestCase |
9 |
||
10 |
from os.path import join |
|
11 |
||
12 |
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
|
13 |
from cubicweb.appobject import AppObject |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
14 |
from cubicweb.cwvreg import CubicWebVRegistry, UnknownProperty |
777
39695e98ba35
test and fix interface based objects cleaning
sylvain.thenault@logilab.fr
parents:
750
diff
changeset
|
15 |
from cubicweb.devtools import TestServerConfiguration |
4490
d45cde54d464
backport stable branch and some vreg cleanups:
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
16 |
from cubicweb.devtools.testlib import CubicWebTC |
777
39695e98ba35
test and fix interface based objects cleaning
sylvain.thenault@logilab.fr
parents:
750
diff
changeset
|
17 |
from cubicweb.interfaces import IMileStone |
0 | 18 |
|
1640 | 19 |
from cubes.card.entities import Card |
20 |
||
0 | 21 |
class YesSchema: |
22 |
def __contains__(self, something): |
|
23 |
return True |
|
1341 | 24 |
|
25 |
WEBVIEWSDIR = join(BASE, 'web', 'views') |
|
1640 | 26 |
|
0 | 27 |
class VRegistryTC(TestCase): |
28 |
||
29 |
def setUp(self): |
|
777
39695e98ba35
test and fix interface based objects cleaning
sylvain.thenault@logilab.fr
parents:
750
diff
changeset
|
30 |
config = TestServerConfiguration('data') |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
31 |
self.vreg = CubicWebVRegistry(config) |
777
39695e98ba35
test and fix interface based objects cleaning
sylvain.thenault@logilab.fr
parents:
750
diff
changeset
|
32 |
config.bootstrap_cubes() |
39695e98ba35
test and fix interface based objects cleaning
sylvain.thenault@logilab.fr
parents:
750
diff
changeset
|
33 |
self.vreg.schema = config.load_schema() |
1640 | 34 |
|
0 | 35 |
def test_load_interface_based_vojects(self): |
1341 | 36 |
self.vreg.init_registration([WEBVIEWSDIR]) |
1640 | 37 |
self.vreg.load_file(join(BASE, 'entities', '__init__.py'), 'cubicweb.entities.__init__') |
1341 | 38 |
self.vreg.load_file(join(WEBVIEWSDIR, 'idownloadable.py'), 'cubicweb.web.views.idownloadable') |
1640 | 39 |
self.vreg.load_file(join(WEBVIEWSDIR, 'primary.py'), 'cubicweb.web.views.primary') |
0 | 40 |
self.assertEquals(len(self.vreg['views']['primary']), 2) |
1640 | 41 |
self.vreg.initialization_completed() |
42 |
self.assertEquals(len(self.vreg['views']['primary']), 1) |
|
43 |
||
777
39695e98ba35
test and fix interface based objects cleaning
sylvain.thenault@logilab.fr
parents:
750
diff
changeset
|
44 |
|
2657
de974465d381
[appobject] kill VObject class, move base selector classes to appobject
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2650
diff
changeset
|
45 |
def test_load_subinterface_based_appobjects(self): |
777
39695e98ba35
test and fix interface based objects cleaning
sylvain.thenault@logilab.fr
parents:
750
diff
changeset
|
46 |
self.vreg.reset() |
39695e98ba35
test and fix interface based objects cleaning
sylvain.thenault@logilab.fr
parents:
750
diff
changeset
|
47 |
self.vreg.register_objects([join(BASE, 'web', 'views', 'iprogress.py')]) |
39695e98ba35
test and fix interface based objects cleaning
sylvain.thenault@logilab.fr
parents:
750
diff
changeset
|
48 |
# check progressbar was kicked |
39695e98ba35
test and fix interface based objects cleaning
sylvain.thenault@logilab.fr
parents:
750
diff
changeset
|
49 |
self.failIf(self.vreg['views'].get('progressbar')) |
39695e98ba35
test and fix interface based objects cleaning
sylvain.thenault@logilab.fr
parents:
750
diff
changeset
|
50 |
class MyCard(Card): |
39695e98ba35
test and fix interface based objects cleaning
sylvain.thenault@logilab.fr
parents:
750
diff
changeset
|
51 |
__implements__ = (IMileStone,) |
39695e98ba35
test and fix interface based objects cleaning
sylvain.thenault@logilab.fr
parents:
750
diff
changeset
|
52 |
self.vreg.reset() |
1341 | 53 |
self.vreg._loadedmods[__name__] = {} |
4491
a0f48c31b58a
kill register_appobject_class method, simplifying autoregistration. Update test accordingly (test which manually registers object should also properly call there __register__ method). Drop the disable-appobjects config file entry: no one used it since its introduction years ago.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4490
diff
changeset
|
54 |
self.vreg.register(MyCard) |
1640 | 55 |
self.vreg.register_objects([join(BASE, 'entities', '__init__.py'), |
56 |
join(BASE, 'web', 'views', 'iprogress.py')]) |
|
777
39695e98ba35
test and fix interface based objects cleaning
sylvain.thenault@logilab.fr
parents:
750
diff
changeset
|
57 |
# check progressbar isn't kicked |
39695e98ba35
test and fix interface based objects cleaning
sylvain.thenault@logilab.fr
parents:
750
diff
changeset
|
58 |
self.assertEquals(len(self.vreg['views']['progressbar']), 1) |
1640 | 59 |
|
4485
5f99eb0b99f7
initialize property once initialization has been fully completed, close #666573
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
60 |
def test_properties(self): |
5f99eb0b99f7
initialize property once initialization has been fully completed, close #666573
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
61 |
self.failIf('system.version.cubicweb' in self.vreg['propertydefs']) |
5f99eb0b99f7
initialize property once initialization has been fully completed, close #666573
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
62 |
self.failUnless(self.vreg.property_info('system.version.cubicweb')) |
5f99eb0b99f7
initialize property once initialization has been fully completed, close #666573
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
63 |
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
|
64 |
|
4490
d45cde54d464
backport stable branch and some vreg cleanups:
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
65 |
|
d45cde54d464
backport stable branch and some vreg cleanups:
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
66 |
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
|
67 |
|
5f99eb0b99f7
initialize property once initialization has been fully completed, close #666573
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
68 |
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
|
69 |
# 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
|
70 |
from cubicweb.web.views.xmlrss import RSSIconBox |
4490
d45cde54d464
backport stable branch and some vreg cleanups:
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
71 |
self.assertEquals(self.vreg.property_info(RSSIconBox._cwpropkey('visible'))['default'], True) |
0 | 72 |
|
73 |
if __name__ == '__main__': |
|
74 |
unittest_main() |