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.interfaces import IUniversity |
---|
9 | from waeup.sirp.testing import FunctionalLayer, FunctionalTestCase |
---|
10 | |
---|
11 | class UniversityTests(FunctionalTestCase): |
---|
12 | |
---|
13 | layer = FunctionalLayer |
---|
14 | |
---|
15 | def setUp(self): |
---|
16 | super(UniversityTests, self).setUp() |
---|
17 | self.workdir = tempfile.mkdtemp() |
---|
18 | self.getRootFolder()['app'] = University() |
---|
19 | self.app = self.getRootFolder()['app'] |
---|
20 | return |
---|
21 | |
---|
22 | def tearDown(self): |
---|
23 | super(UniversityTests, self).tearDown() |
---|
24 | shutil.rmtree(self.workdir) |
---|
25 | return |
---|
26 | |
---|
27 | def test_ifaces(self): |
---|
28 | university = University() |
---|
29 | assert verifyClass(IUniversity, University) |
---|
30 | assert verifyObject(IUniversity, university) |
---|
31 | return |
---|
32 | |
---|
33 | def test_IFileRetrieval_utility(self): |
---|
34 | # Make sure we can get a local IFileRetrieval utility |
---|
35 | setSite(self.app) |
---|
36 | result = queryUtility(IFileRetrieval, default=None) |
---|
37 | assert result is not None |
---|
38 | assert IFileRetrieval.providedBy(result) |
---|
39 | return |
---|
40 | |
---|
41 | def test_update_plugins(self): |
---|
42 | # We can update plugins |
---|
43 | setSite(self.app) |
---|
44 | del self.app['accesscodes'] |
---|
45 | self.app.updatePlugins() |
---|
46 | self.assertTrue('accesscodes' in self.app.keys()) |
---|