[7193] | 1 | ## $Id: test_app.py 14511 2017-02-07 08:33:05Z henrik $ |
---|
| 2 | ## |
---|
| 3 | ## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann |
---|
| 4 | ## This program is free software; you can redistribute it and/or modify |
---|
| 5 | ## it under the terms of the GNU General Public License as published by |
---|
| 6 | ## the Free Software Foundation; either version 2 of the License, or |
---|
| 7 | ## (at your option) any later version. |
---|
| 8 | ## |
---|
| 9 | ## This program is distributed in the hope that it will be useful, |
---|
| 10 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 11 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 12 | ## GNU General Public License for more details. |
---|
| 13 | ## |
---|
| 14 | ## You should have received a copy of the GNU General Public License |
---|
| 15 | ## along with this program; if not, write to the Free Software |
---|
| 16 | ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
| 17 | ## |
---|
[6523] | 18 | import tempfile |
---|
| 19 | import shutil |
---|
| 20 | from hurry.file.interfaces import IFileRetrieval |
---|
| 21 | from zope.component import queryUtility |
---|
[6532] | 22 | from zope.component.hooks import setSite |
---|
[6523] | 23 | from zope.interface.verify import verifyClass, verifyObject |
---|
[7811] | 24 | from waeup.kofa.app import University |
---|
[9217] | 25 | from waeup.kofa.interfaces import ( |
---|
| 26 | IUniversity, IJobManager, VIRT_JOBS_CONTAINER_NAME) |
---|
[7811] | 27 | from waeup.kofa.testing import FunctionalLayer, FunctionalTestCase |
---|
[6523] | 28 | |
---|
| 29 | class UniversityTests(FunctionalTestCase): |
---|
| 30 | |
---|
| 31 | layer = FunctionalLayer |
---|
| 32 | |
---|
| 33 | def setUp(self): |
---|
| 34 | super(UniversityTests, self).setUp() |
---|
| 35 | self.workdir = tempfile.mkdtemp() |
---|
| 36 | self.getRootFolder()['app'] = University() |
---|
| 37 | self.app = self.getRootFolder()['app'] |
---|
| 38 | return |
---|
| 39 | |
---|
| 40 | def tearDown(self): |
---|
| 41 | super(UniversityTests, self).tearDown() |
---|
| 42 | shutil.rmtree(self.workdir) |
---|
| 43 | return |
---|
| 44 | |
---|
| 45 | def test_ifaces(self): |
---|
| 46 | university = University() |
---|
| 47 | assert verifyClass(IUniversity, University) |
---|
| 48 | assert verifyObject(IUniversity, university) |
---|
| 49 | return |
---|
| 50 | |
---|
| 51 | def test_IFileRetrieval_utility(self): |
---|
| 52 | # Make sure we can get a local IFileRetrieval utility |
---|
| 53 | setSite(self.app) |
---|
| 54 | result = queryUtility(IFileRetrieval, default=None) |
---|
| 55 | assert result is not None |
---|
| 56 | assert IFileRetrieval.providedBy(result) |
---|
| 57 | return |
---|
[6593] | 58 | |
---|
[14511] | 59 | def disabled_test_update_plugins(self): |
---|
[6593] | 60 | # We can update plugins |
---|
| 61 | setSite(self.app) |
---|
[12472] | 62 | del self.app['documents'] |
---|
[6593] | 63 | self.app.updatePlugins() |
---|
[12472] | 64 | self.assertTrue('documents' in self.app.keys()) |
---|
[9217] | 65 | return |
---|
| 66 | |
---|
| 67 | def test_jobs(self): |
---|
| 68 | # We can get the global job manager when traversing to it... |
---|
| 69 | result = self.app.traverse(VIRT_JOBS_CONTAINER_NAME) |
---|
| 70 | self.assertTrue(IJobManager.providedBy(result)) |
---|
| 71 | return |
---|