[test/windmill] Gracefully skip windmill test if windmill can't be imported.
If windmill import fails the windmill module is set to None and a dummy
CubicWebWindmillUseCase test class is create. This class contains a test that
skip itself with a proper warning message.
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr## This file is part of CubicWeb.## CubicWeb is free software: you can redistribute it and/or modify it under the# terms of the GNU Lesser General Public License as published by the Free# Software Foundation, either version 2.1 of the License, or (at your option)# any later version.## CubicWeb is distributed in the hope that it will be useful, but WITHOUT# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more# details.## You should have received a copy of the GNU Lesser General Public License along# with CubicWeb. If not, see <http://www.gnu.org/licenses/>.fromlogilab.common.testlibimportunittest_main,TestCasefromos.pathimportjoinfromcubicwebimportCW_SOFTWARE_ROOTasBASEfromcubicweb.appobjectimportAppObjectfromcubicweb.cwvregimportCubicWebVRegistry,UnknownPropertyfromcubicweb.devtoolsimportTestServerConfigurationfromcubicweb.devtools.testlibimportCubicWebTCfromcubicweb.viewimportEntityAdapterfromcubes.card.entitiesimportCardclassYesSchema:def__contains__(self,something):returnTrueWEBVIEWSDIR=join(BASE,'web','views')classVRegistryTC(TestCase):defsetUp(self):config=TestServerConfiguration('data')self.vreg=CubicWebVRegistry(config)config.bootstrap_cubes()self.vreg.schema=config.load_schema()deftest_load_interface_based_vojects(self):self.vreg.init_registration([WEBVIEWSDIR])self.vreg.load_file(join(BASE,'entities','__init__.py'),'cubicweb.entities.__init__')self.vreg.load_file(join(WEBVIEWSDIR,'idownloadable.py'),'cubicweb.web.views.idownloadable')self.vreg.load_file(join(WEBVIEWSDIR,'primary.py'),'cubicweb.web.views.primary')self.assertEqual(len(self.vreg['views']['primary']),2)self.vreg.initialization_completed()self.assertEqual(len(self.vreg['views']['primary']),1)deftest_load_subinterface_based_appobjects(self):self.vreg.register_objects([join(BASE,'web','views','iprogress.py')])# check progressbar was kickedself.failIf(self.vreg['views'].get('progressbar'))# we've to emulate register_objects to add custom MyCard objectspath=[join(BASE,'entities','__init__.py'),join(BASE,'entities','adapters.py'),join(BASE,'web','views','iprogress.py')]filemods=self.vreg.init_registration(path,None)forfilepath,modnameinfilemods:self.vreg.load_file(filepath,modname)classCardIProgressAdapter(EntityAdapter):__regid__='IProgress'self.vreg._loadedmods[__name__]={}self.vreg.register(CardIProgressAdapter)self.vreg.initialization_completed()# check progressbar isn't kickedself.assertEqual(len(self.vreg['views']['progressbar']),1)deftest_properties(self):self.vreg.reset()self.failIf('system.version.cubicweb'inself.vreg['propertydefs'])self.failUnless(self.vreg.property_info('system.version.cubicweb'))self.assertRaises(UnknownProperty,self.vreg.property_info,'a.non.existent.key')classCWVregTC(CubicWebTC):deftest_property_default_overriding(self):# see data/views.pyfromcubicweb.web.views.xmlrssimportRSSIconBoxself.assertEqual(self.vreg.property_info(RSSIconBox._cwpropkey('visible'))['default'],True)if__name__=='__main__':unittest_main()