13 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
13 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
14 # details. |
14 # details. |
15 # |
15 # |
16 # You should have received a copy of the GNU Lesser General Public License along |
16 # You should have received a copy of the GNU Lesser General Public License along |
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
18 """ |
|
19 |
18 |
20 """ |
|
21 from logilab.common.testlib import unittest_main, TestCase |
19 from logilab.common.testlib import unittest_main, TestCase |
22 |
20 |
23 from os.path import join |
21 from os.path import join |
24 |
22 |
25 from cubicweb import CW_SOFTWARE_ROOT as BASE |
23 from cubicweb import CW_SOFTWARE_ROOT as BASE |
26 from cubicweb.appobject import AppObject |
24 from cubicweb.appobject import AppObject |
27 from cubicweb.cwvreg import CubicWebVRegistry, UnknownProperty |
25 from cubicweb.cwvreg import CubicWebVRegistry, UnknownProperty |
28 from cubicweb.devtools import TestServerConfiguration |
26 from cubicweb.devtools import TestServerConfiguration |
29 from cubicweb.devtools.testlib import CubicWebTC |
27 from cubicweb.devtools.testlib import CubicWebTC |
30 from cubicweb.interfaces import IMileStone |
28 from cubicweb.view import EntityAdapter |
31 |
29 |
32 from cubes.card.entities import Card |
30 from cubes.card.entities import Card |
33 |
31 |
34 class YesSchema: |
32 class YesSchema: |
35 def __contains__(self, something): |
33 def __contains__(self, something): |
59 self.vreg.register_objects([join(BASE, 'web', 'views', 'iprogress.py')]) |
57 self.vreg.register_objects([join(BASE, 'web', 'views', 'iprogress.py')]) |
60 # check progressbar was kicked |
58 # check progressbar was kicked |
61 self.failIf(self.vreg['views'].get('progressbar')) |
59 self.failIf(self.vreg['views'].get('progressbar')) |
62 # we've to emulate register_objects to add custom MyCard objects |
60 # we've to emulate register_objects to add custom MyCard objects |
63 path = [join(BASE, 'entities', '__init__.py'), |
61 path = [join(BASE, 'entities', '__init__.py'), |
|
62 join(BASE, 'entities', 'adapters.py'), |
64 join(BASE, 'web', 'views', 'iprogress.py')] |
63 join(BASE, 'web', 'views', 'iprogress.py')] |
65 filemods = self.vreg.init_registration(path, None) |
64 filemods = self.vreg.init_registration(path, None) |
66 for filepath, modname in filemods: |
65 for filepath, modname in filemods: |
67 self.vreg.load_file(filepath, modname) |
66 self.vreg.load_file(filepath, modname) |
68 class MyCard(Card): |
67 class CardIProgressAdapter(EntityAdapter): |
69 __implements__ = (IMileStone,) |
68 __regid__ = 'IProgress' |
70 self.vreg._loadedmods[__name__] = {} |
69 self.vreg._loadedmods[__name__] = {} |
71 self.vreg.register(MyCard) |
70 self.vreg.register(CardIProgressAdapter) |
72 self.vreg.initialization_completed() |
71 self.vreg.initialization_completed() |
73 # check progressbar isn't kicked |
72 # check progressbar isn't kicked |
74 self.assertEquals(len(self.vreg['views']['progressbar']), 1) |
73 self.assertEquals(len(self.vreg['views']['progressbar']), 1) |
75 |
74 |
76 def test_properties(self): |
75 def test_properties(self): |