[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/tests - test_viewpackage.py:1.2 testServiceManager.py:1.6
Jim Fulton
jim@zope.com
Thu, 19 Dec 2002 15:38:57 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/tests
In directory cvs.zope.org:/tmp/cvs-serv26340/lib/python/Zope/App/OFS/Services/ServiceManager/tests
Modified Files:
testServiceManager.py
Added Files:
test_viewpackage.py
Log Message:
Merged changes made by Albertas and Jim from the AdapterAndView-branch
branch:
- Added TTW adapter service
Todo:
o Named adapters
o Getting classes in persistent modules working so we can actually
create TTW adapters.
- Added TTW view service
o View service
o View configurations
For configuting views from view factories
o Page configurations
For configuring views based on templates (and optional classes)
o View (sub)packages. These get added to packages. You configure
them with default configuration info and then add page templates
to them. Added page temlates are automatically added as views with
the same name.
=== Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/tests/test_viewpackage.py 1.1 => 1.2 ===
--- /dev/null Thu Dec 19 15:38:57 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/tests/test_viewpackage.py Thu Dec 19 15:38:26 2002
@@ -0,0 +1,68 @@
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""View package tests.
+
+$Id$
+"""
+
+from unittest import TestCase, TestSuite, main, makeSuite
+from Zope.App.OFS.Services.ServiceManager.tests.PlacefulSetup \
+ import PlacefulSetup
+from Zope.App.OFS.Services.ServiceManager.viewpackage import ViewPackage
+from Zope.App.Traversing import traverse
+from Zope.App.OFS.Services.zpt import ZPTTemplate
+from Zope.App.OFS.Services.view import ViewService
+from Zope.App.OFS.Services.ConfigurationInterfaces import Active
+from Zope.App.OFS.Services.ServiceManager.ServiceManager import ServiceManager
+from Zope.App.OFS.Services.ServiceManager.ServiceConfiguration \
+ import ServiceConfiguration
+from Interface import Interface
+
+class Test(PlacefulSetup, TestCase):
+
+ def test_setObject(self):
+ self.buildFolders()
+ self.rootFolder.setServiceManager(ServiceManager())
+ default = traverse(self.rootFolder, '++etc++Services/Packages/default')
+ default.setObject('Views', ViewPackage())
+ views = traverse(default, 'Views')
+ views.forInterface = Interface
+ views.factoryName = None
+
+ #set up view service
+ default.setObject('ViewService', ViewService())
+ configure = traverse(default, 'configure')
+ configuration = ServiceConfiguration(
+ 'Views',
+ '/++etc++Services/Packages/default/ViewService')
+ configure.setObject('', configuration)
+ configuration = traverse(configure, '1')
+ configuration.status = Active
+
+ views.setObject('foo.html', ZPTTemplate())
+
+ configuration = traverse(views, 'configure/1')
+ self.assertEqual(configuration.status, Active)
+
+ self.assertRaises(TypeError,
+ views.setObject, 'bar.html', ViewPackage())
+
+
+def test_suite():
+ return TestSuite((
+ makeSuite(Test),
+ ))
+
+if __name__=='__main__':
+ main(defaultTest='test_suite')
=== Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/tests/testServiceManager.py 1.5 => 1.6 ===
--- Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/tests/testServiceManager.py:1.5 Thu Dec 12 06:32:33 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/tests/testServiceManager.py Thu Dec 19 15:38:26 2002
@@ -74,6 +74,25 @@
self.assertEqual(c(c(c(c(testOb)))), self.rootFolder)
self.assertEqual(testOb, ts)
+ def test_get(self):
+ self.createServiceManager()
+ sm = traverse(self.rootFolder, '++etc++Services')
+ default = traverse(sm, 'Packages/default')
+
+ ts = TestService()
+ default.setObject('test_service1', ts)
+ configuration = ServiceConfiguration(
+ 'test_service',
+ '/++etc++Services/Packages/default/test_service1')
+
+ default['configure'].setObject('', configuration)
+ traverse(default, 'configure/1').status = Active
+
+ testOb = sm.get('test_service')
+ self.assertEqual(testOb, ts)
+ testOb = sm.get('test_service2')
+ self.assertEqual(testOb, None)
+
def testAddService(self):
self.createServiceManager()
sm = traverse(self.rootFolder, '++etc++Services')