author | sylvain.thenault@logilab.fr |
Tue, 10 Mar 2009 19:35:38 +0100 | |
branch | tls-sprint |
changeset 1036 | 593df4919845 |
parent 777 | 39695e98ba35 |
child 1341 | 9502d02630bf |
permissions | -rw-r--r-- |
0 | 1 |
from logilab.common.testlib import unittest_main, TestCase |
2 |
||
3 |
from os.path import join |
|
4 |
||
5 |
from cubicweb import CW_SOFTWARE_ROOT as BASE |
|
6 |
from cubicweb.vregistry import VObject |
|
7 |
from cubicweb.cwvreg import CubicWebRegistry, UnknownProperty |
|
777
39695e98ba35
test and fix interface based objects cleaning
sylvain.thenault@logilab.fr
parents:
750
diff
changeset
|
8 |
from cubicweb.devtools import TestServerConfiguration |
39695e98ba35
test and fix interface based objects cleaning
sylvain.thenault@logilab.fr
parents:
750
diff
changeset
|
9 |
from cubicweb.entities.lib import Card |
39695e98ba35
test and fix interface based objects cleaning
sylvain.thenault@logilab.fr
parents:
750
diff
changeset
|
10 |
from cubicweb.interfaces import IMileStone |
0 | 11 |
|
12 |
class YesSchema: |
|
13 |
def __contains__(self, something): |
|
14 |
return True |
|
15 |
||
16 |
class VRegistryTC(TestCase): |
|
17 |
||
18 |
def setUp(self): |
|
777
39695e98ba35
test and fix interface based objects cleaning
sylvain.thenault@logilab.fr
parents:
750
diff
changeset
|
19 |
config = TestServerConfiguration('data') |
0 | 20 |
self.vreg = CubicWebRegistry(config) |
777
39695e98ba35
test and fix interface based objects cleaning
sylvain.thenault@logilab.fr
parents:
750
diff
changeset
|
21 |
config.bootstrap_cubes() |
39695e98ba35
test and fix interface based objects cleaning
sylvain.thenault@logilab.fr
parents:
750
diff
changeset
|
22 |
self.vreg.schema = config.load_schema() |
0 | 23 |
|
24 |
def test_load(self): |
|
25 |
self.vreg.load_file(join(BASE, 'web', 'views'), 'euser.py') |
|
26 |
self.vreg.load_file(join(BASE, 'web', 'views'), 'baseviews.py') |
|
631
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
27 |
fpvc = [v for v in self.vreg.registry_objects('views', 'primary') |
633 | 28 |
if v.__module__ == 'cubicweb.web.views.euser'][0] |
0 | 29 |
fpv = fpvc(None, None) |
30 |
# don't want a TypeError due to super call |
|
31 |
self.assertRaises(AttributeError, fpv.render_entity_attributes, None, None) |
|
32 |
||
33 |
def test_load_interface_based_vojects(self): |
|
34 |
self.vreg.load_file(join(BASE, 'web', 'views'), 'idownloadable.py') |
|
35 |
self.vreg.load_file(join(BASE, 'web', 'views'), 'baseviews.py') |
|
36 |
# check loading baseviews after idownloadable isn't kicking interface based views |
|
37 |
self.assertEquals(len(self.vreg['views']['primary']), 2) |
|
38 |
||
740 | 39 |
def test___selectors__compat(self): |
0 | 40 |
myselector1 = lambda *args: 1 |
41 |
myselector2 = lambda *args: 1 |
|
42 |
class AnAppObject(VObject): |
|
43 |
__selectors__ = (myselector1, myselector2) |
|
740 | 44 |
AnAppObject.build___select__() |
45 |
self.assertEquals(AnAppObject.__select__(AnAppObject), 2) |
|
0 | 46 |
|
47 |
def test_properties(self): |
|
48 |
self.failIf('system.version.cubicweb' in self.vreg['propertydefs']) |
|
49 |
self.failUnless(self.vreg.property_info('system.version.cubicweb')) |
|
50 |
self.assertRaises(UnknownProperty, self.vreg.property_info, 'a.non.existent.key') |
|
777
39695e98ba35
test and fix interface based objects cleaning
sylvain.thenault@logilab.fr
parents:
750
diff
changeset
|
51 |
|
39695e98ba35
test and fix interface based objects cleaning
sylvain.thenault@logilab.fr
parents:
750
diff
changeset
|
52 |
def test_load_subinterface_based_vobjects(self): |
39695e98ba35
test and fix interface based objects cleaning
sylvain.thenault@logilab.fr
parents:
750
diff
changeset
|
53 |
self.vreg.reset() |
39695e98ba35
test and fix interface based objects cleaning
sylvain.thenault@logilab.fr
parents:
750
diff
changeset
|
54 |
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
|
55 |
# check progressbar was kicked |
39695e98ba35
test and fix interface based objects cleaning
sylvain.thenault@logilab.fr
parents:
750
diff
changeset
|
56 |
self.failIf(self.vreg['views'].get('progressbar')) |
39695e98ba35
test and fix interface based objects cleaning
sylvain.thenault@logilab.fr
parents:
750
diff
changeset
|
57 |
class MyCard(Card): |
39695e98ba35
test and fix interface based objects cleaning
sylvain.thenault@logilab.fr
parents:
750
diff
changeset
|
58 |
__implements__ = (IMileStone,) |
39695e98ba35
test and fix interface based objects cleaning
sylvain.thenault@logilab.fr
parents:
750
diff
changeset
|
59 |
self.vreg.reset() |
39695e98ba35
test and fix interface based objects cleaning
sylvain.thenault@logilab.fr
parents:
750
diff
changeset
|
60 |
self.vreg.register_vobject_class(MyCard) |
39695e98ba35
test and fix interface based objects cleaning
sylvain.thenault@logilab.fr
parents:
750
diff
changeset
|
61 |
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
|
62 |
# check progressbar isn't kicked |
39695e98ba35
test and fix interface based objects cleaning
sylvain.thenault@logilab.fr
parents:
750
diff
changeset
|
63 |
self.assertEquals(len(self.vreg['views']['progressbar']), 1) |
0 | 64 |
|
65 |
||
66 |
if __name__ == '__main__': |
|
67 |
unittest_main() |