[10765] | 1 | ## $Id: test_applicant.py 15000 2018-05-06 10:16:09Z 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 | ## |
---|
| 18 | """Tests for applicants and related. |
---|
| 19 | """ |
---|
| 20 | import grok |
---|
| 21 | import shutil |
---|
| 22 | import tempfile |
---|
| 23 | from StringIO import StringIO |
---|
| 24 | from zope.component import adapts, queryUtility |
---|
| 25 | from zope.component.interfaces import IFactory |
---|
| 26 | from zope.interface import verify, implements |
---|
| 27 | from zope.location.interfaces import ILocation |
---|
| 28 | from waeup.kofa.image.interfaces import IKofaImageFile |
---|
| 29 | from waeup.kofa.imagestorage import DefaultStorage |
---|
| 30 | from waeup.kofa.interfaces import IFileStoreHandler, IFileStoreNameChooser |
---|
| 31 | from waeup.kofa.testing import FunctionalTestCase |
---|
[15000] | 32 | from kofacustom.edopoly.applicants.applicant import ( |
---|
[10765] | 33 | CustomApplicant, CustomApplicantFactory, |
---|
| 34 | ) |
---|
[15000] | 35 | from kofacustom.edopoly.applicants.interfaces import ICustomApplicant |
---|
| 36 | from kofacustom.edopoly.testing import FunctionalLayer |
---|
[10765] | 37 | |
---|
| 38 | class CustomApplicantTest(FunctionalTestCase): |
---|
| 39 | |
---|
| 40 | layer = FunctionalLayer |
---|
| 41 | |
---|
| 42 | def setUp(self): |
---|
| 43 | super(CustomApplicantTest, self).setUp() |
---|
| 44 | self.applicant = CustomApplicant() |
---|
| 45 | return |
---|
| 46 | |
---|
| 47 | def tearDown(self): |
---|
| 48 | super(CustomApplicantTest, self).tearDown() |
---|
| 49 | return |
---|
| 50 | |
---|
| 51 | def test_interfaces(self): |
---|
| 52 | verify.verifyClass(ICustomApplicant, CustomApplicant) |
---|
| 53 | verify.verifyObject(ICustomApplicant, self.applicant) |
---|
| 54 | return |
---|
| 55 | |
---|
| 56 | class CustomApplicantFactoryTest(FunctionalTestCase): |
---|
| 57 | |
---|
| 58 | layer = FunctionalLayer |
---|
| 59 | |
---|
| 60 | def setUp(self): |
---|
| 61 | super(CustomApplicantFactoryTest, self).setUp() |
---|
| 62 | self.factory = CustomApplicantFactory() |
---|
| 63 | return |
---|
| 64 | |
---|
| 65 | def tearDown(self): |
---|
| 66 | super(CustomApplicantFactoryTest, self).tearDown() |
---|
| 67 | return |
---|
| 68 | |
---|
| 69 | def test_interfaces(self): |
---|
| 70 | verify.verifyClass(IFactory, CustomApplicantFactory) |
---|
| 71 | verify.verifyObject(IFactory, self.factory) |
---|
| 72 | |
---|
| 73 | def test_factory(self): |
---|
| 74 | obj = self.factory() |
---|
| 75 | assert isinstance(obj, CustomApplicant) |
---|
| 76 | |
---|
| 77 | def test_getInterfaces(self): |
---|
| 78 | implemented_by = self.factory.getInterfaces() |
---|
| 79 | assert implemented_by.isOrExtends(ICustomApplicant) |
---|