1 | ## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann |
---|
2 | ## This program is free software; you can redistribute it and/or modify |
---|
3 | ## it under the terms of the GNU General Public License as published by |
---|
4 | ## the Free Software Foundation; either version 2 of the License, or |
---|
5 | ## (at your option) any later version. |
---|
6 | ## |
---|
7 | ## This program is distributed in the hope that it will be useful, |
---|
8 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
9 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
10 | ## GNU General Public License for more details. |
---|
11 | ## |
---|
12 | ## You should have received a copy of the GNU General Public License |
---|
13 | ## along with this program; if not, write to the Free Software |
---|
14 | ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
15 | ## |
---|
16 | """Tests for configuration containers and related. |
---|
17 | """ |
---|
18 | from zope.component.interfaces import IFactory |
---|
19 | from zope.interface import verify |
---|
20 | from waeup.sirp.testing import FunctionalLayer, FunctionalTestCase |
---|
21 | from waeup.sirp.configuration import ConfigurationContainer |
---|
22 | from waeup.sirp.interfaces import IConfigurationContainer |
---|
23 | from waeup.sirp.tests.test_configuration import ( |
---|
24 | ConfigurationTest, SessionConfigurationFactoryTest) |
---|
25 | from waeup.custom.configuration import ( |
---|
26 | SessionConfiguration, SessionConfigurationFactory) |
---|
27 | from waeup.custom.interfaces import( |
---|
28 | ISessionConfiguration, ISessionConfigurationAdd) |
---|
29 | |
---|
30 | |
---|
31 | class ConfigurationTest(ConfigurationTest): |
---|
32 | |
---|
33 | layer = FunctionalLayer |
---|
34 | |
---|
35 | def setUp(self): |
---|
36 | super(ConfigurationTest, self).setUp() |
---|
37 | self.confcontainer = ConfigurationContainer() |
---|
38 | self.sessionconf = SessionConfiguration() |
---|
39 | return |
---|
40 | |
---|
41 | #def tearDown(self): |
---|
42 | # super(ConfigurationTest, self).tearDown() |
---|
43 | # return |
---|
44 | |
---|
45 | def test_interfaces(self): |
---|
46 | #verify.verifyClass(IConfigurationContainer, ConfigurationContainer) |
---|
47 | #verify.verifyObject(IConfigurationContainer, self.confcontainer) |
---|
48 | verify.verifyClass(ISessionConfiguration, SessionConfiguration) |
---|
49 | verify.verifyObject(ISessionConfiguration, self.sessionconf) |
---|
50 | verify.verifyClass(ISessionConfigurationAdd, SessionConfiguration) |
---|
51 | verify.verifyObject(ISessionConfigurationAdd, self.sessionconf) |
---|
52 | |
---|
53 | class SessionConfigurationFactoryTest(SessionConfigurationFactoryTest): |
---|
54 | |
---|
55 | layer = FunctionalLayer |
---|
56 | |
---|
57 | def setUp(self): |
---|
58 | super(SessionConfigurationFactoryTest, self).setUp() |
---|
59 | self.factory = SessionConfigurationFactory() |
---|
60 | |
---|
61 | #def tearDown(self): |
---|
62 | # super(SessionConfigurationFactoryTest, self).tearDown() |
---|
63 | |
---|
64 | def test_interfaces(self): |
---|
65 | verify.verifyClass(IFactory, SessionConfigurationFactory) |
---|
66 | verify.verifyObject(IFactory, self.factory) |
---|
67 | |
---|
68 | def test_factory(self): |
---|
69 | obj = self.factory() |
---|
70 | assert isinstance(obj, SessionConfiguration) |
---|
71 | |
---|
72 | def test_getInterfaces(self): |
---|
73 | implemented_by = self.factory.getInterfaces() |
---|
74 | assert implemented_by.isOrExtends(ISessionConfiguration) |
---|