source: main/waeup.sirp/trunk/src/waeup/sirp/tests/test_app.py @ 7026

Last change on this file since 7026 was 6593, checked in by uli, 13 years ago

Make sure, plugin updates work basically.

File size: 1.7 KB
Line 
1import tempfile
2import shutil
3from hurry.file.interfaces import IFileRetrieval
4from zope.component import queryUtility
5from zope.component.hooks import setSite
6from zope.interface.verify import verifyClass, verifyObject
7from waeup.sirp.app import University
8from waeup.sirp.imagestorage import ImageStorageFileRetrieval
9from waeup.sirp.interfaces import IUniversity
10from waeup.sirp.testing import FunctionalLayer, FunctionalTestCase
11
12class UniversityTests(FunctionalTestCase):
13
14    layer = FunctionalLayer
15
16    def setUp(self):
17        super(UniversityTests, self).setUp()
18        self.workdir = tempfile.mkdtemp()
19        self.getRootFolder()['app'] = University()
20        self.app = self.getRootFolder()['app']
21        return
22
23    def tearDown(self):
24        super(UniversityTests, self).tearDown()
25        shutil.rmtree(self.workdir)
26        return
27
28    def test_ifaces(self):
29        university = University()
30        assert verifyClass(IUniversity, University)
31        assert verifyObject(IUniversity, university)
32        return
33
34    def test_images(self):
35        # Make sure we have a image container in a university
36        assert 'images' in self.app.keys()
37        return
38
39    def test_IFileRetrieval_utility(self):
40        # Make sure we can get a local IFileRetrieval utility
41        setSite(self.app)
42        result = queryUtility(IFileRetrieval, default=None)
43        assert result is not None
44        assert IFileRetrieval.providedBy(result)
45        assert isinstance(result, ImageStorageFileRetrieval)
46        return
47
48    def test_update_plugins(self):
49        # We can update plugins
50        setSite(self.app)
51        del self.app['accesscodes']
52        self.app.updatePlugins()
53        self.assertTrue('accesscodes' in self.app.keys())
Note: See TracBrowser for help on using the repository browser.