1 | import tempfile |
---|
2 | import shutil |
---|
3 | from hurry.file.interfaces import IFileRetrieval |
---|
4 | from zope.component import queryUtility |
---|
5 | from zope.component.hooks import setSite |
---|
6 | from zope.interface.verify import verifyClass, verifyObject |
---|
7 | from waeup.sirp.app import University |
---|
8 | from waeup.sirp.imagestorage import ImageStorageFileRetrieval |
---|
9 | from waeup.sirp.interfaces import IUniversity |
---|
10 | from waeup.sirp.testing import FunctionalLayer, FunctionalTestCase |
---|
11 | |
---|
12 | class 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 |
---|