import tempfile import shutil from hurry.file.interfaces import IFileRetrieval from zope.component import queryUtility from zope.component.hooks import setSite from zope.interface.verify import verifyClass, verifyObject from waeup.sirp.app import University from waeup.sirp.imagestorage import ImageStorageFileRetrieval from waeup.sirp.interfaces import IUniversity from waeup.sirp.testing import FunctionalLayer, FunctionalTestCase class UniversityTests(FunctionalTestCase): layer = FunctionalLayer def setUp(self): super(UniversityTests, self).setUp() self.workdir = tempfile.mkdtemp() self.getRootFolder()['app'] = University() self.app = self.getRootFolder()['app'] return def tearDown(self): super(UniversityTests, self).tearDown() shutil.rmtree(self.workdir) return def test_ifaces(self): university = University() assert verifyClass(IUniversity, University) assert verifyObject(IUniversity, university) return def test_images(self): # Make sure we have a image container in a university assert 'images' in self.app.keys() return def test_IFileRetrieval_utility(self): # Make sure we can get a local IFileRetrieval utility setSite(self.app) result = queryUtility(IFileRetrieval, default=None) assert result is not None assert IFileRetrieval.providedBy(result) assert isinstance(result, ImageStorageFileRetrieval) return def test_update_plugins(self): # We can update plugins setSite(self.app) del self.app['accesscodes'] self.app.updatePlugins() self.assertTrue('accesscodes' in self.app.keys())