[Zope3-checkins] CVS: Zope3/src/zope/app/services/tests - eventsetup.py:1.8 placefulsetup.py:1.23 test_adapter.py:1.16 test_auth.py:1.15 test_cacheconfiguration.py:1.11 test_cachingservice.py:1.10 test_configurationmanager.py:1.9 test_configurationregistry.py:1.7 test_configurations.py:1.7 test_configurationstatusproperty.py:1.7 test_connectionconfiguration.py:1.12 test_connectionservice.py:1.9 test_eventservice.py:1.24 test_module.py:1.7 test_pagefolder.py:1.4 test_principalannotation.py:1.6 test_roleservice.py:1.3 test_serviceconfiguration.py:1.10 test_servicemanager.py:1.11 test_utility.py:1.7 test_view.py:1.15 servicemanager.py:NONE
Jim Fulton
jim@zope.com
Tue, 3 Jun 2003 17:43:33 -0400
Update of /cvs-repository/Zope3/src/zope/app/services/tests
In directory cvs.zope.org:/tmp/cvs-serv29620/src/zope/app/services/tests
Modified Files:
eventsetup.py placefulsetup.py test_adapter.py test_auth.py
test_cacheconfiguration.py test_cachingservice.py
test_configurationmanager.py test_configurationregistry.py
test_configurations.py test_configurationstatusproperty.py
test_connectionconfiguration.py test_connectionservice.py
test_eventservice.py test_module.py test_pagefolder.py
test_principalannotation.py test_roleservice.py
test_serviceconfiguration.py test_servicemanager.py
test_utility.py test_view.py
Removed Files:
servicemanager.py
Log Message:
Refactored the setup machinery for placefull tests.
Most of the setup code is now available in stand-alone functions in
zope.app.tests.setup. These include high-level functions for setting
up service managers and services.
Simplified existing tests to use the new setup facilities, removing
lots of icky code.
=== Zope3/src/zope/app/services/tests/eventsetup.py 1.7 => 1.8 ===
--- Zope3/src/zope/app/services/tests/eventsetup.py:1.7 Thu May 1 15:35:35 2003
+++ Zope3/src/zope/app/services/tests/eventsetup.py Tue Jun 3 17:43:00 2003
@@ -17,15 +17,10 @@
$Id$
"""
from zope.app.services.tests.placefulsetup import PlacefulSetup
-from zope.app.services.service import ServiceManager
class EventSetup(PlacefulSetup):
def setUp(self):
- PlacefulSetup.setUp(self)
- self.buildFolders()
+ PlacefulSetup.setUp(self, site=True)
self.createStandardServices()
-
- def createServiceManager(self, folder):
- folder.setServiceManager(ServiceManager())
=== Zope3/src/zope/app/services/tests/placefulsetup.py 1.22 => 1.23 ===
--- Zope3/src/zope/app/services/tests/placefulsetup.py:1.22 Sun Jun 1 11:59:36 2003
+++ Zope3/src/zope/app/services/tests/placefulsetup.py Tue Jun 3 17:43:00 2003
@@ -16,226 +16,77 @@
Revision information:
$Id$
"""
-from zope.app.attributeannotations import AttributeAnnotations
-from zope.app.browser.absoluteurl import SiteAbsoluteURL, AbsoluteURL
-from zope.app.component import hooks
-from zope.app.container.traversal import ContainerTraversable
-from zope.app.dependable import Dependable
-from zope.app.interfaces.annotation import IAnnotations
-from zope.app.interfaces.annotation import IAttributeAnnotatable
-from zope.app.interfaces.container import ISimpleReadContainer
-from zope.app.interfaces.dependable import IDependable
-from zope.app.interfaces.services.configuration import Active
-from zope.app.interfaces.services.configuration import IAttributeUseConfigurable
-from zope.app.interfaces.services.configuration import IUseConfiguration
-from zope.app.interfaces.traversing import IContainmentRoot
-from zope.app.interfaces.traversing import IContainmentRoot
-from zope.app.interfaces.traversing import IPhysicallyLocatable
-from zope.app.interfaces.traversing import ITraverser, ITraversable
-from zope.app.services.configuration import UseConfiguration
-from zope.app.services.service import ServiceManager, ServiceConfiguration
-from zope.app.services.servicenames import EventPublication, EventSubscription
-from zope.app.services.servicenames import HubIds
+
+from zope.app import zapi
+from zope.app.tests import setup
from zope.app.tests.placelesssetup import PlacelessSetup
-from zope.app.traversing.adapters import DefaultTraversable
-from zope.app.traversing.adapters import Traverser, RootPhysicallyLocatable
-from zope.app.traversing.adapters import WrapperPhysicallyLocatable
-from zope.app.traversing import traverse, getPath
-from zope.app.traversing.namespace import etc, provideNamespaceHandler
-from zope.component.adapter import provideAdapter
-from zope.component.view import provideView
-from zope import component as CA
-from zope.publisher.interfaces.browser import IBrowserPresentation
+from zope.app.services.servicenames import HubIds
+from zope.app.content.folder import RootFolder
+from zope.app.context import ContextWrapper
+
+class Place(object):
+
+ def __init__(self, path):
+ self.path = path
+
+ def __get__(self, inst, cls=None):
+ if inst is None:
+ return self
+
+ try: root = inst.rootFolder
+ except AttributeError:
+ root = inst.rootFolder = setup.buildSampleFolderTree()
+
+ root = ContextWrapper(root, None)
+ return zapi.traverse(root, self.path)
class PlacefulSetup(PlacelessSetup):
- def setUp(self):
- PlacelessSetup.setUp(self)
- # set up placeful hooks, saving originals for tearDown
- CA.getServiceManager.sethook(hooks.getServiceManager_hook)
- self.setUpTraversal()
-
- def setUpTraversal(self):
-
- provideAdapter(None, ITraverser, Traverser)
- provideAdapter(None, ITraversable, DefaultTraversable)
-
- provideAdapter(
- ISimpleReadContainer, ITraversable, ContainerTraversable)
- provideAdapter(
- None, IPhysicallyLocatable, WrapperPhysicallyLocatable)
- provideAdapter(
- IContainmentRoot, IPhysicallyLocatable, RootPhysicallyLocatable)
-
- provideAdapter(IAttributeUseConfigurable, IUseConfiguration,
- UseConfiguration)
- provideAdapter(IAttributeAnnotatable, IAnnotations,
- AttributeAnnotations)
-
- provideAdapter(IAttributeAnnotatable, IDependable, Dependable)
-
- # set up etc namespace
- provideNamespaceHandler("etc", etc)
-
- provideView(None, "absolute_url", IBrowserPresentation,
- AbsoluteURL)
- provideView(IContainmentRoot, "absolute_url", IBrowserPresentation,
- SiteAbsoluteURL)
+ # Places :)
+ rootFolder = Place('')
+
+ folder1 = Place('folder1')
+ folder1_1 = Place('folder1/folder1_1')
+ folder1_1_1 = Place('folder1/folder1_1/folder1_1_1')
+ folder1_1_2 = Place('folder1/folder1_2/folder1_1_2')
+ folder1_2 = Place('folder1/folder1_2')
+ folder1_2_1 = Place('folder1/folder1_2/folder1_2_1')
+
+ folder2 = Place('folder2')
+ folder2_1 = Place('folder2/folder2_1')
+ folder2_1_1 = Place('folder2/folder2_1/folder2_1_1')
+
+ def setUp(self, folders=False, site=False):
+ setup.placefullSetUp()
+ if folders or site:
+ return self.buildFolders(site)
def tearDown(self):
+ setup.placefullTearDown()
# clean up folders and placeful service managers and services too?
- CA.getServiceManager.reset()
- PlacelessSetup.tearDown(self)
-
- def buildFolders(self):
- # set up a reasonably complex folder structure
- #
- # ____________ rootFolder ____________
- # / \
- # folder1 __________________ folder2
- # | \ |
- # folder1_1 ____ folder1_2 folder2_1
- # | \ | |
- # folder1_1_1 folder1_1_2 folder1_2_1 folder2_1_1
- from zope.app.content.folder import Folder
- from zope.app.context import ContextWrapper
- # top
- self.createRootFolder()
- # level 1
- self.folder1 = Folder()
- self.rootFolder.setObject("folder1", self.folder1)
- self.folder1 = ContextWrapper(self.folder1, self.rootFolder,
- name = "folder1")
- self.folder2 = Folder()
- self.rootFolder.setObject("folder2", self.folder2)
- self.folder2 = ContextWrapper(self.folder2, self.rootFolder,
- name = "folder2")
- # level 2
- self.folder1_1 = Folder()
- self.folder1.setObject("folder1_1", self.folder1_1)
- self.folder1_1 = ContextWrapper(self.folder1_1, self.folder1,
- name = "folder1_1")
- self.folder1_2 = Folder()
- self.folder1.setObject("folder1_2", self.folder1_2)
- self.folder1_2 = ContextWrapper(self.folder1_2, self.folder1,
- name = "folder1_2")
- self.folder2_1 = Folder()
- self.folder2.setObject("folder2_1", self.folder2_1)
- self.folder2_1 = ContextWrapper(self.folder2_1, self.folder2,
- name = "folder2_1")
- # level 3
- self.folder1_1_1 = Folder()
- self.folder1_1.setObject("folder1_1_1", self.folder1_1_1)
- self.folder1_1_1 = ContextWrapper(self.folder1_1_1, self.folder1_1,
- name = "folder1_1_1")
- self.folder1_1_2 = Folder()
- self.folder1_1.setObject("folder1_1_2", self.folder1_1_2)
- self.folder1_1_2 = ContextWrapper(self.folder1_1_2, self.folder1_1,
- name = "folder1_1_2")
- self.folder1_2_1 = Folder()
- self.folder1_2.setObject("folder1_2_1", self.folder1_2_1)
- self.folder1_2_1 = ContextWrapper(self.folder1_2_1, self.folder1_2,
- name = "folder1_2_1")
- self.folder2_1_1 = Folder()
- self.folder2_1.setObject("folder2_1_1", self.folder2_1_1)
- self.folder2_1_1 = ContextWrapper(self.folder2_1_1, self.folder2_1,
- name = "folder2_1_1")
-
- def createServiceManager(self, folder=None):
- if folder is None:
- folder = self.rootFolder
- from zope.app.services.tests.servicemanager \
- import TestingServiceManager
- folder.setServiceManager(TestingServiceManager())
+ def buildFolders(self, site=False):
+ self.rootFolder = setup.buildSampleFolderTree()
+ if site:
+ return self.makeSite()
+
+ def makeSite(self, path='/'):
+ folder = zapi.traverse(self.rootFolder, path)
+ return setup.createServiceManager(folder)
+
def createRootFolder(self):
- from zope.app.content.folder import RootFolder
+ self.rootFolder
self.rootFolder = RootFolder()
+ # The following is a hook that some base classes might want to override.
def getObjectHub(self):
from zope.app.services.hub import ObjectHub
return ObjectHub()
- def createEventService(self, folder_path):
- """Create an event service in 'folder', and configure it for
- EventPublication and EventSubscription services."""
- folder = traverse(self.rootFolder, folder_path)
- if not folder.hasServiceManager():
- folder.setServiceManager(ServiceManager())
- sm = traverse(folder, '++etc++site')
- default = traverse(sm, 'default')
- service_name = 'anEventService'
- from zope.app.services.event import EventService
- default.setObject(service_name, EventService())
-
- path = "%s/%s" % (getPath(default), service_name)
- configuration = ServiceConfiguration(EventPublication, path, self.rootFolder)
- default.getConfigurationManager().setObject(
- "%sEventsDir" % service_name, configuration)
- traverse(default.getConfigurationManager(), '1').status = Active
-
- configuration = ServiceConfiguration(EventSubscription, path,
- self.rootFolder)
- default.getConfigurationManager().setObject(
- "%sSubscriptionServiceDir" % service_name, configuration)
- traverse(default.getConfigurationManager(), '2').status = Active
-
def createStandardServices(self):
'''Create a bunch of standard placeful services'''
- if not hasattr(self, 'rootFolder'):
- self.createRootFolder()
- root = self.rootFolder
- if root.hasServiceManager():
- raise RuntimeError('ServiceManager already exists, so cannot '
- 'create standard services')
- root.setServiceManager(ServiceManager())
- from zope.component import getServiceManager
- defineService = getServiceManager(None).defineService
-
- from zope.app.interfaces.services.hub import IObjectHub
- from zope.app.interfaces.services.event import ISubscriptionService
- from zope.app.services.event import EventService
- defineService(EventSubscription, ISubscriptionService)
-
- # EventPublication service already defined by
- # zope.app.events.tests.PlacelessSetup
-
- defineService(HubIds, IObjectHub)
-
- sm = traverse(root, '++etc++site')
- default = traverse(sm, 'default')
- default.setObject("myEventService", EventService())
- default.setObject("myObjectHub", self.getObjectHub())
-
- path = "%s/default/myEventService" % getPath(sm)
- configuration = ServiceConfiguration(EventPublication, path,
- self.rootFolder)
- default.getConfigurationManager().setObject(
- "myEventServiceDir", configuration)
- traverse(default.getConfigurationManager(), '1').status = Active
-
- configuration = ServiceConfiguration(EventSubscription, path,
- self.rootFolder)
- default.getConfigurationManager().setObject(
- "mySubscriptionServiceDir", configuration)
- traverse(default.getConfigurationManager(), '2').status = Active
-
- path = "%s/default/myObjectHub" % getPath(sm)
- configuration = ServiceConfiguration(HubIds, path, self.rootFolder)
- default.getConfigurationManager().setObject("myHubIdsServiceDir",
- configuration)
- traverse(default.getConfigurationManager(), '3').status = Active
-
-def addService(servicemanager, name, service):
- default = traverse(servicemanager, 'default')
- default.setObject(name, service)
- path = "%s/default/%s" % (getPath(servicemanager), name)
- configuration = ServiceConfiguration(name, path, servicemanager)
- default.getConfigurationManager().setObject("", configuration)
- traverse(default.getConfigurationManager(), '1').status = Active
-
-def createServiceManager(folder):
- folder.setServiceManager(ServiceManager())
- return traverse(folder, "++etc++site")
+ setup.createStandardServices(self.rootFolder,
+ hubids=self.getObjectHub())
+
=== Zope3/src/zope/app/services/tests/test_adapter.py 1.15 => 1.16 ===
--- Zope3/src/zope/app/services/tests/test_adapter.py:1.15 Mon Jun 2 15:40:49 2003
+++ Zope3/src/zope/app/services/tests/test_adapter.py Tue Jun 3 17:43:00 2003
@@ -71,9 +71,7 @@
class TestAdapterService(PlacefulSetup, TestingIConfigurable, TestCase):
def setUp(self):
- PlacefulSetup.setUp(self)
- self.buildFolders()
- self.rootFolder.setServiceManager(ServiceManager())
+ PlacefulSetup.setUp(self, site=True)
self._service = ContextWrapper(AdapterService(), self.rootFolder)
def test_implements_IAdapterService(self):
@@ -221,9 +219,6 @@
def test_queryAdapter_delegation(self):
service = self._service
- self.buildFolders()
- self.rootFolder.setServiceManager(ServiceManager())
-
sm = traverse(self.rootFolder, '++etc++site')
configure = traverse(sm, 'default').getConfigurationManager()
@@ -293,6 +288,7 @@
PlacefulSetup.setUp(self)
rootFolder = RootFolder()
rootFolder.setServiceManager(PhonyServiceManager())
+
self.configuration = ContextWrapper(
AdapterConfiguration(I1, I2, "Foo.Bar.A", "adapter"),
rootFolder,
=== Zope3/src/zope/app/services/tests/test_auth.py 1.14 => 1.15 ===
--- Zope3/src/zope/app/services/tests/test_auth.py:1.14 Tue Jun 3 10:50:38 2003
+++ Zope3/src/zope/app/services/tests/test_auth.py Tue Jun 3 17:43:00 2003
@@ -22,13 +22,12 @@
from zope.exceptions import NotFoundError
from zope.publisher.interfaces.http import IHTTPCredentials
-from zope.app.services.service import ServiceConfiguration
from zope.app.services.tests.eventsetup import EventSetup
from zope.app.traversing import getPath, traverse
-from zope.app.interfaces.services.configuration import Active
from zope.app.container.tests.test_icontainer import BaseTestIContainer
from zope.interface import implements
+from zope.app.tests import setup
class Request:
@@ -56,22 +55,9 @@
getService(None, Adapters).provideAdapter(
IHTTPCredentials, ILoginPassword, BasicAuthAdapter)
- folder = self.rootFolder
-
- if not folder.hasServiceManager():
- self.createServiceManager(folder)
-
- default = traverse(folder, '++etc++site/default')
- key = default.setObject("AuthenticationService",
- AuthenticationService())
- auth = traverse(default, key)
-
- path = getPath(auth)
- configuration = ServiceConfiguration(Authentication, path)
- configure = default.getConfigurationManager()
- key = configure.setObject('', configuration)
- traverse(configure, key).status = Active
-
+ sm = traverse(self.rootFolder, '++etc++site')
+ auth = setup.addService(sm, Authentication, AuthenticationService())
+
auth.setObject('srichter', User('srichter', 'Stephan', 'Richter',
'srichter', 'hello'))
auth.setObject('jim', User('jim', 'Jim', 'Fulton',
=== Zope3/src/zope/app/services/tests/test_cacheconfiguration.py 1.10 => 1.11 ===
--- Zope3/src/zope/app/services/tests/test_cacheconfiguration.py:1.10 Sun Jun 1 11:59:36 2003
+++ Zope3/src/zope/app/services/tests/test_cacheconfiguration.py Tue Jun 3 17:43:00 2003
@@ -16,24 +16,25 @@
$Id$
"""
__metaclass__ = type
+
from unittest import TestCase, main, makeSuite
-from zope.app.services.cache import CacheConfiguration
-from zope.app.services.tests.placefulsetup import PlacefulSetup
-from zope.app.traversing import traverse
-from zope.app.services.service import ServiceManager
from zope.app.container.zopecontainer import ZopeContainerAdapter
-from zope.app.interfaces.services.configuration import Active, Unregistered
+from zope.app.context import ContextWrapper
from zope.app.interfaces.cache.cache import ICache
-from zope.app.interfaces.dependable import IDependable
from zope.app.interfaces.cache.cache import ICachingService
-from zope.app.interfaces.services.configuration import IConfigurable
+from zope.app.interfaces.dependable import IDependable
+from zope.app.interfaces.event import IObjectModifiedEvent
+from zope.app.interfaces.services.configuration import Active, Unregistered
from zope.app.interfaces.services.configuration import IAttributeUseConfigurable
+from zope.app.interfaces.services.configuration import IConfigurable
+from zope.app.interfaces.services.service import ILocalService
+from zope.app.services.cache import CacheConfiguration
from zope.app.services.configuration import ConfigurationRegistry
-from zope.app.services.service import ServiceConfiguration
+from zope.app.services.service import ServiceManager
+from zope.app.services.tests.placefulsetup import PlacefulSetup
+from zope.app.tests import setup
+from zope.app.traversing import traverse
from zope.context import ContextMethod
-from zope.app.context import ContextWrapper
-from zope.app.interfaces.event import IObjectModifiedEvent
-
class DependableStub:
@@ -60,7 +61,7 @@
class CachingServiceStub(DependableStub):
__implements__ = (ICachingService, IConfigurable, IDependable,
- IAttributeUseConfigurable)
+ IAttributeUseConfigurable, ILocalService)
def __init__(self):
self.bindings = {}
@@ -100,9 +101,9 @@
class TestConnectionConfiguration(PlacefulSetup, TestCase):
def setUp(self):
- PlacefulSetup.setUp(self)
- self.buildFolders()
- self.rootFolder.setServiceManager(ServiceManager())
+ sm = PlacefulSetup.setUp(self, site=True)
+ self.service = setup.addService(sm, 'Caching', CachingServiceStub())
+
self.default = traverse(self.rootFolder,
'++etc++site/default')
@@ -110,16 +111,10 @@
self.cch = traverse(self.default, 'cch')
self.cm = ZopeContainerAdapter(self.default.getConfigurationManager())
- self.cm.setObject('', CacheConfiguration('cache_name',
- '/++etc++site/default/cch'))
- self.config = traverse(self.default.getConfigurationManager(), '1')
-
- self.default.setObject('cache_srv', CachingServiceStub())
- self.service = traverse(self.default, 'cache_srv')
-
- self.cm.setObject('', ServiceConfiguration('Caching',
- '/++etc++site/default/cache_srv'))
- traverse(self.default.getConfigurationManager(), '2').status = Active
+ key = self.cm.setObject('',
+ CacheConfiguration('cache_name',
+ '/++etc++site/default/cch'))
+ self.config = traverse(self.default.getConfigurationManager(), key)
def tearDown(self):
PlacefulSetup.tearDown(self)
=== Zope3/src/zope/app/services/tests/test_cachingservice.py 1.9 => 1.10 ===
--- Zope3/src/zope/app/services/tests/test_cachingservice.py:1.9 Tue Jun 3 10:48:57 2003
+++ Zope3/src/zope/app/services/tests/test_cachingservice.py Tue Jun 3 17:43:00 2003
@@ -17,6 +17,7 @@
"""
from unittest import TestCase, TestSuite, main, makeSuite
+from zope.app.tests import setup
from zope.interface.verify import verifyObject
from zope.interface import implements
from zope.app.interfaces.cache.cache import ICache
@@ -24,7 +25,6 @@
from zope.app.services.cache import CacheConfiguration
from zope.app.interfaces.services.configuration import Active, Registered
from zope.app.services.tests.eventsetup import EventSetup
-from zope.app.services.service import ServiceConfiguration
from zope.app.traversing import getPath, traverse
def sort(list):
@@ -49,22 +49,8 @@
def createCachingService(self, path=None):
from zope.app.services.cache import CachingService
- folder = self.rootFolder
- if path is not None:
- folder = traverse(folder, path)
-
- if not folder.hasServiceManager():
- self.createServiceManager(folder)
-
- default = traverse(folder, '++etc++site/default')
- key = default.setObject("myCachingService", CachingService())
- service = traverse(default, key)
-
- path = getPath(service)
- configuration = ServiceConfiguration("Caching", path)
- configure = default.getConfigurationManager()
- key = configure.setObject('', configuration)
- traverse(configure, key).status = Active
+ sm = self.makeSite(path)
+ return setup.addService(sm, "Caching", CachingService())
return service
=== Zope3/src/zope/app/services/tests/test_configurationmanager.py 1.8 => 1.9 ===
--- Zope3/src/zope/app/services/tests/test_configurationmanager.py:1.8 Thu May 1 15:35:35 2003
+++ Zope3/src/zope/app/services/tests/test_configurationmanager.py Tue Jun 3 17:43:00 2003
@@ -345,8 +345,7 @@
class ConfigurationManagerContainerTests(placefulsetup.PlacefulSetup):
def test_getConfigurationManager(self):
- self.buildFolders()
- sm = placefulsetup.createServiceManager(self.rootFolder)
+ sm = self.buildFolders(site=True)
default = traverse(sm, 'default')
self.assertEqual(default.getConfigurationManager(),
default['RegistrationManager'])
@@ -362,8 +361,7 @@
## default.getConfigurationManager)
def test_cant_remove_last_cm(self):
- self.buildFolders()
- sm = placefulsetup.createServiceManager(self.rootFolder)
+ sm = self.buildFolders(site=True)
default = traverse(sm, 'default')
self.assertRaises(Exception,
default.__delitem__, 'configuration')
=== Zope3/src/zope/app/services/tests/test_configurationregistry.py 1.6 => 1.7 ===
--- Zope3/src/zope/app/services/tests/test_configurationregistry.py:1.6 Sun Jun 1 11:59:36 2003
+++ Zope3/src/zope/app/services/tests/test_configurationregistry.py Tue Jun 3 17:43:00 2003
@@ -39,11 +39,8 @@
class Test(PlacefulSetup, TestCase):
def setUp(self):
- PlacefulSetup.setUp(self)
- self.buildFolders()
+ PlacefulSetup.setUp(self, site=True)
root = self.rootFolder
-
- root.setServiceManager(ServiceManager())
self.__default = traverse(root, "++etc++site/default")
self.__registry = ContextWrapper(ConfigurationRegistry(), root)
=== Zope3/src/zope/app/services/tests/test_configurations.py 1.6 => 1.7 ===
--- Zope3/src/zope/app/services/tests/test_configurations.py:1.6 Sun Jun 1 11:59:36 2003
+++ Zope3/src/zope/app/services/tests/test_configurations.py Tue Jun 3 17:43:00 2003
@@ -24,10 +24,7 @@
from zope.app.interfaces.dependable import DependencyError
from zope.app.services.configuration import SimpleConfiguration
from zope.app.services.configuration import ComponentConfiguration
-from zope.app.services.tests.placefulsetup \
- import PlacefulSetup
-from zope.app.services.tests.servicemanager \
- import TestingServiceManager
+from zope.app.services.tests.placefulsetup import PlacefulSetup
from zope.app.context import ContextWrapper
from zope.app.interfaces.dependable import IDependable
from zope.app.traversing import traverse
@@ -81,10 +78,7 @@
class TestComponentConfiguration(TestSimpleConfiguration, PlacefulSetup):
def setUp(self):
- PlacefulSetup.setUp(self)
- self.buildFolders()
- self.__sm = TestingServiceManager()
- self.rootFolder.setServiceManager(self.__sm)
+ PlacefulSetup.setUp(self, site=True)
self.name = 'foo'
def test_getComponent(self):
=== Zope3/src/zope/app/services/tests/test_configurationstatusproperty.py 1.6 => 1.7 ===
--- Zope3/src/zope/app/services/tests/test_configurationstatusproperty.py:1.6 Sun Jun 1 11:59:36 2003
+++ Zope3/src/zope/app/services/tests/test_configurationstatusproperty.py Tue Jun 3 17:43:00 2003
@@ -82,8 +82,7 @@
class Test(PlacefulSetup, TestCase):
def setUp(self):
- PlacefulSetup.setUp(self)
- self.buildFolders()
+ PlacefulSetup.setUp(self, folders=True)
self.__sm = TestingServiceManager()
self.rootFolder.setServiceManager(self.__sm)
=== Zope3/src/zope/app/services/tests/test_connectionconfiguration.py 1.11 => 1.12 ===
--- Zope3/src/zope/app/services/tests/test_connectionconfiguration.py:1.11 Sun Jun 1 11:59:36 2003
+++ Zope3/src/zope/app/services/tests/test_connectionconfiguration.py Tue Jun 3 17:43:00 2003
@@ -30,11 +30,12 @@
from zope.app.interfaces.rdb import IConnectionService
from zope.app.interfaces.services.configuration import IConfigurable
from zope.app.services.configuration import ConfigurationRegistry
-from zope.app.services.service import ServiceConfiguration
from zope.context import ContextMethod
from zope.app.context import ContextWrapper
from zope.app.interfaces.services.configuration \
import IAttributeUseConfigurable, IUseConfiguration
+from zope.app.tests import setup
+from zope.app.interfaces.services.service import ILocalService
class DependableStub:
@@ -61,7 +62,7 @@
class ConnectionServiceStub(DependableStub):
__implements__ = (IConnectionService, IConfigurable, IDependable,
- IAttributeUseConfigurable)
+ IAttributeUseConfigurable, ILocalService)
def __init__(self):
self.bindings = {}
@@ -91,9 +92,9 @@
class TestConnectionConfiguration(PlacefulSetup, TestCase):
def setUp(self):
- PlacefulSetup.setUp(self)
- self.buildFolders()
- self.rootFolder.setServiceManager(ServiceManager())
+ sm = PlacefulSetup.setUp(self, site=True)
+ self.service = setup.addService(sm, 'SQLDatabaseConnections',
+ ConnectionServiceStub())
self.default = traverse(self.rootFolder,
'++etc++site/default')
@@ -101,16 +102,10 @@
self.da = traverse(self.default, 'da')
self.cm = ZopeContainerAdapter(self.default.getConfigurationManager())
- self.cm.setObject('', ConnectionConfiguration('conn_name',
- '/++etc++site/default/da'))
- self.config = traverse(self.default.getConfigurationManager(), '1')
-
- self.default.setObject('conn_srv', ConnectionServiceStub())
- self.service = traverse(self.default, 'conn_srv')
-
- self.cm.setObject('', ServiceConfiguration('SQLDatabaseConnections',
- '/++etc++site/default/conn_srv'))
- traverse(self.default.getConfigurationManager(), '2').status = Active
+ key = self.cm.setObject('',
+ ConnectionConfiguration('conn_name',
+ '/++etc++site/default/da'))
+ self.config = traverse(self.default.getConfigurationManager(), key)
def tearDown(self):
PlacefulSetup.tearDown(self)
=== Zope3/src/zope/app/services/tests/test_connectionservice.py 1.8 => 1.9 ===
--- Zope3/src/zope/app/services/tests/test_connectionservice.py:1.8 Thu May 1 15:35:35 2003
+++ Zope3/src/zope/app/services/tests/test_connectionservice.py Tue Jun 3 17:43:00 2003
@@ -32,11 +32,12 @@
from zope.app.services.configuration import UseConfiguration
from zope.app.services.connection import ConnectionConfiguration
from zope.app.services.connection import ConnectionService
-from zope.app.services.service import ServiceConfiguration
from zope.app.services.service import ServiceManager
from zope.app.services.tests.placefulsetup import PlacefulSetup
from zope.app.traversing import traverse
from zope.component.adapter import provideAdapter
+from zope.app.tests import setup
+from zope.app import zapi
class ConnectionServiceForTests(ConnectionService):
@@ -62,65 +63,44 @@
class TestConnectionService(unittest.TestCase, PlacefulSetup):
def setUp(self):
- PlacefulSetup.setUp(self)
-
- provideAdapter(IAttributeAnnotatable,
- IAnnotations, AttributeAnnotations)
- provideAdapter(IAnnotatable, IDependable, Dependable)
- provideAdapter(IAttributeAnnotatable, IUseConfiguration,
- UseConfiguration)
-
- # Set up a local connection service
- self.buildFolders()
- self.rootFolder.setServiceManager(ServiceManager())
-
- self.default = traverse(self.rootFolder,
- '++etc++site/default')
- self.default.setObject('conn_srv', ConnectionServiceForTests())
- self.service = traverse(self.default, 'conn_srv')
-
- self.cm = ZopeContainerAdapter(self.default.getConfigurationManager())
- self.cm.setObject('', ServiceConfiguration('SQLDatabaseConnections',
- '/++etc++site/default/conn_srv'))
- traverse(self.default.getConfigurationManager(), '1').status = Active
+ sm = PlacefulSetup.setUp(self, site=True)
+ self.service = setup.addService(sm, 'SQLDatabaseConnections',
+ ConnectionServiceForTests())
+ self.default = zapi.traverse(sm, 'default')
self.default.setObject('da1', DAStub(1))
self.default.setObject('da2', DAStub(2))
- self.cm.setObject('', ConnectionConfiguration('conn1',
+ self.cm = ZopeContainerAdapter(self.default.getConfigurationManager())
+
+ k = self.cm.setObject('', ConnectionConfiguration('conn1',
'/++etc++site/default/da1'))
- traverse(self.default.getConfigurationManager(), '2').status = Active
- self.cm.setObject('', ConnectionConfiguration('conn2',
+ traverse(self.default.getConfigurationManager(), k).status = Active
+ k = self.cm.setObject('', ConnectionConfiguration('conn2',
'/++etc++site/default/da2'))
- traverse(self.default.getConfigurationManager(), '3').status = Active
- self.cm.setObject('', ConnectionConfiguration('conn3',
+ traverse(self.default.getConfigurationManager(), k).status = Active
+ k = self.cm.setObject('', ConnectionConfiguration('conn3',
'/++etc++site/default/da1'))
traverse(self.default.getConfigurationManager(),
- '4').status = Registered
+ k).status = Registered
# Now self.service has conn1 and conn2 available and knows about conn3
- # Set up a more local connection service
- folder1 = traverse(self.rootFolder, 'folder1')
- folder1.setServiceManager(ServiceManager())
-
- default1 = traverse(folder1, '++etc++site/default')
- default1.setObject('conn_srv1', ConnectionServiceForTests())
- self.service1 = traverse(default1, 'conn_srv1')
-
- cm1 = ZopeContainerAdapter(default1.getConfigurationManager())
- cm1.setObject('', ServiceConfiguration('SQLDatabaseConnections',
- '/folder1/++etc++site/default/conn_srv1'))
- traverse(default1.getConfigurationManager(), '1').status = Active
+ sm = self.makeSite('folder1')
+ self.service1 = setup.addService(sm, 'SQLDatabaseConnections',
+ ConnectionServiceForTests())
+ default1 = traverse(sm, 'default')
default1.setObject('da3', DAStub(3))
default1.setObject('da4', DAStub(4))
+
+ cm1 = ZopeContainerAdapter(default1.getConfigurationManager())
- cm1.setObject('', ConnectionConfiguration('conn1',
+ k = cm1.setObject('', ConnectionConfiguration('conn1',
'/folder1/++etc++site/default/da3'))
- traverse(default1.getConfigurationManager(), '2').status = Active
- cm1.setObject('', ConnectionConfiguration('conn4',
+ traverse(default1.getConfigurationManager(), k).status = Active
+ k = cm1.setObject('', ConnectionConfiguration('conn4',
'/folder1/++etc++site/default/da4'))
- traverse(default1.getConfigurationManager(), '3').status = Active
+ traverse(default1.getConfigurationManager(), k).status = Active
# Now self.service1 overrides conn1, adds new conn4 available, and
# inherits conn2 from self.service
=== Zope3/src/zope/app/services/tests/test_eventservice.py 1.23 => 1.24 ===
--- Zope3/src/zope/app/services/tests/test_eventservice.py:1.23 Tue Jun 3 10:45:28 2003
+++ Zope3/src/zope/app/services/tests/test_eventservice.py Tue Jun 3 17:43:00 2003
@@ -19,7 +19,6 @@
from unittest import TestCase, TestLoader, TextTestRunner
from zope.interface import Interface, implements
-from zope.app.services.service import ServiceManager, ServiceConfiguration
from zope.app.services.servicenames import EventPublication, EventSubscription
from zope.app.services.event import EventService
from zope.app.traversing import getPath, traverse
@@ -40,6 +39,8 @@
from zope.component.tests.components import RecordingAdapter
from zope.component.adapter import provideAdapter
from zope.app.interfaces.services.service import ISimpleService
+from zope.app.services.event import EventService
+from zope.app.tests import setup
class UnpromotingEventService(EventService):
@@ -119,9 +120,12 @@
return self.objectHub
def _createNestedServices(self):
- self.createEventService('folder1')
- self.createEventService('folder1/folder1_1')
- self.createEventService('folder1/folder1_1/folder1_1_1')
+ for path in ('folder1', 'folder1/folder1_1',
+ 'folder1/folder1_1/folder1_1_1'):
+ sm = self.makeSite(path)
+ events = EventService()
+ setup.addService(sm, EventPublication, events)
+ setup.addService(sm, EventSubscription, events, suffix='s')
def _createSubscribers(self):
self.rootFolder.setObject("rootFolderSubscriber", DummySubscriber())
@@ -826,23 +830,9 @@
self.folder2,
name="folder2Subscriber")
- if not self.folder2.hasServiceManager():
- self.folder2.setServiceManager(ServiceManager())
-
- sm = traverse(self.rootFolder, 'folder2/++etc++site')
- default = traverse(sm, 'default')
-
- default.setObject("myEventService", service)
-
- path = "%s/default/myEventService" % getPath(sm)
- configuration = ServiceConfiguration(EventPublication, path)
- default.getConfigurationManager().setObject("myEventServiceDir", configuration)
- traverse(default.getConfigurationManager(), '1').status = Active
-
- configuration = ServiceConfiguration(EventSubscription, path)
- default.getConfigurationManager().setObject("mySubscriptionServiceDir",
- configuration)
- traverse(default.getConfigurationManager(), '2').status = Active
+ sm = self.makeSite('folder2')
+ setup.addService(sm, EventPublication, service);
+ setup.addService(sm, EventSubscription, service, suffix='s');
subscribe(
self.rootFolderSubscriber,
=== Zope3/src/zope/app/services/tests/test_module.py 1.6 => 1.7 ===
--- Zope3/src/zope/app/services/tests/test_module.py:1.6 Thu May 1 15:35:35 2003
+++ Zope3/src/zope/app/services/tests/test_module.py Tue Jun 3 17:43:00 2003
@@ -38,14 +38,9 @@
class ServiceManagerTests(PlacefulSetup, TestCase):
def setUp(self):
- PlacefulSetup.setUp(self)
- self.buildFolders()
-
- def _Test__new(self):
- return ServiceManager()
+ PlacefulSetup.setUp(self, site=True)
def test_resolve(self):
- self.rootFolder.setServiceManager(ServiceManager())
sm = traverse(self.rootFolder, "++etc++site")
default = traverse(sm, "default")
default.setObject('m1', Manager())
=== Zope3/src/zope/app/services/tests/test_pagefolder.py 1.3 => 1.4 ===
--- Zope3/src/zope/app/services/tests/test_pagefolder.py:1.3 Sun Mar 23 17:35:42 2003
+++ Zope3/src/zope/app/services/tests/test_pagefolder.py Tue Jun 3 17:43:00 2003
@@ -17,14 +17,13 @@
"""
from unittest import TestCase, TestSuite, main, makeSuite
+from zope.app.tests import setup
from zope.app.services.tests.placefulsetup import PlacefulSetup
from zope.app.services.pagefolder import PageFolder
from zope.app.traversing import traverse
from zope.app.services.zpt import ZPTTemplate
from zope.app.services.view import ViewService
from zope.app.interfaces.services.configuration import Active
-from zope.app.services.service import ServiceManager
-from zope.app.services.service import ServiceConfiguration
from zope.interface import Interface
from zope.publisher.interfaces.browser import IBrowserPresentation
from zope.app.services.tests.test_configurationmanager \
@@ -35,25 +34,16 @@
class Test(ConfigurationManagerContainerTests, PlacefulSetup, TestCase):
def test_setObject(self):
- self.buildFolders()
- self.rootFolder.setServiceManager(ServiceManager())
+ sm = self.buildFolders(site=True)
+ setup.addService(sm, 'Views', ViewService(), suffix='service')
+
+
default = traverse(self.rootFolder, '++etc++site/default')
default.setObject('Views', PageFolder())
views = traverse(default, 'Views')
views.forInterface = I
views.factoryName = None
views.permission = 'zope.View'
-
- #set up view service
- default.setObject('ViewService', ViewService())
- configure = default.getConfigurationManager()
- configuration = ServiceConfiguration(
- 'Views',
- '/++etc++site/default/ViewService')
- configure.setObject('', configuration)
- configuration = traverse(configure, '1')
- configuration.status = Active
-
views.setObject('foo.html', ZPTTemplate())
configuration = traverse(views.getConfigurationManager(), '1')
=== Zope3/src/zope/app/services/tests/test_principalannotation.py 1.5 => 1.6 ===
--- Zope3/src/zope/app/services/tests/test_principalannotation.py:1.5 Tue Jun 3 10:47:05 2003
+++ Zope3/src/zope/app/services/tests/test_principalannotation.py Tue Jun 3 17:43:00 2003
@@ -28,6 +28,7 @@
from zope.component import getAdapter
from zope.app.interfaces.annotation import IAnnotations
from zope.app.interfaces.security import IPrincipal
+from zope.app.tests import setup
class Principal:
@@ -45,7 +46,7 @@
def setUp(self):
PlacefulSetup.setUp(self)
- self.buildFolders()
+ sm = self.buildFolders(site='/')
root_sm = getServiceManager(None)
@@ -55,12 +56,7 @@
IPrincipalAnnotationService)
root_sm.provideService("PrincipalAnnotation", svc)
- self.createServiceManager()
-
- sm = getServiceManager(self.rootFolder)
- sm.PrincipalAnnotation = svc
-
- self.svc = getService(self.rootFolder, "PrincipalAnnotation")
+ self.svc = setup.addService(sm, 'PrincipalAnnotation', svc)
def testGetSimple(self):
prince = Principal('somebody')
@@ -78,10 +74,9 @@
def testGetFromLayered(self):
princeSomebody = Principal('somebody')
- self.createServiceManager(self.folder1)
- sm1 = getServiceManager(self.folder1)
- sm1.PrincipalAnnotation = PrincipalAnnotationService()
- subService = getService(self.folder1, "PrincipalAnnotation")
+ sm1 = self.makeSite('folder1')
+ subService = setup.addService(sm1, 'PrincipalAnnotation',
+ PrincipalAnnotationService())
parentAnnotation = self.svc.getAnnotations(princeSomebody)
=== Zope3/src/zope/app/services/tests/test_roleservice.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/services/tests/test_roleservice.py:1.2 Wed Dec 25 09:13:20 2002
+++ Zope3/src/zope/app/services/tests/test_roleservice.py Tue Jun 3 17:43:00 2003
@@ -16,9 +16,10 @@
Revision information:
$Id$
"""
+
from unittest import TestCase, TestLoader, TextTestRunner
-from zope.app.services.tests.placefulsetup \
- import PlacefulSetup
+from zope.app.tests import setup
+from zope.app.services.tests.placefulsetup import PlacefulSetup
from zope.component import getServiceManager, getService
from zope.app.interfaces.security import IRoleService
from zope.app.security.registries.roleregistry import roleRegistry
@@ -31,8 +32,7 @@
return RoleService()
def setUp(self):
- PlacefulSetup.setUp(self)
- self.buildFolders()
+ sm = PlacefulSetup.setUp(self, site=True)
root_sm = getServiceManager(None)
@@ -40,13 +40,7 @@
self.roleRegistry = roleRegistry
root_sm.provideService("Roles", roleRegistry)
- self.createServiceManager()
-
- sm = getServiceManager(self.rootFolder)
- rs = RoleService()
- sm.Roles = rs
-
- self.rs = getService(self.rootFolder,"Roles")
+ self.rs = setup.addService(sm, 'Roles', RoleService())
def testGetRole(self):
self.roleRegistry.defineRole('Manager', 'Manager', '')
@@ -67,11 +61,8 @@
r = Role("Hacker","","")
self.rs.setObject("Hacker", r)
- self.createServiceManager(self.folder1)
- sm1 = getServiceManager(self.folder1)
- sm1.Roles = RoleService()
-
- rs1 = getService(self.folder1, "Roles")
+ sm1 = self.makeSite('folder1')
+ rs1 = setup.addService(sm1, 'Roles', RoleService())
r1 = Role("Reviewer",'','')
rs1.setObject("Reviewer", r1)
=== Zope3/src/zope/app/services/tests/test_serviceconfiguration.py 1.9 => 1.10 ===
--- Zope3/src/zope/app/services/tests/test_serviceconfiguration.py:1.9 Thu May 1 15:35:35 2003
+++ Zope3/src/zope/app/services/tests/test_serviceconfiguration.py Tue Jun 3 17:43:00 2003
@@ -77,10 +77,10 @@
class Test(PlacefulSetup, TestCase):
def setUp(self):
- PlacefulSetup.setUp(self)
- self.buildFolders()
- self.rootFolder.setServiceManager(ServiceManager())
+ PlacefulSetup.setUp(self, site=True)
+
defineService('test_service', ITestService)
+
default = traverse(self.rootFolder,
'++etc++site/default')
self.__default = default
=== Zope3/src/zope/app/services/tests/test_servicemanager.py 1.10 => 1.11 ===
--- Zope3/src/zope/app/services/tests/test_servicemanager.py:1.10 Sun Jun 1 11:59:36 2003
+++ Zope3/src/zope/app/services/tests/test_servicemanager.py Tue Jun 3 17:43:00 2003
@@ -39,19 +39,10 @@
class ServiceManagerTests(PlacefulSetup, TestCase):
def setUp(self):
- PlacefulSetup.setUp(self)
- self.buildFolders()
-
+ PlacefulSetup.setUp(self, site=True)
serviceManager.defineService('test_service', ITestService)
- def _Test__new(self):
- return ServiceManager()
-
- def createServiceManager(self):
- self.rootFolder.setServiceManager(ServiceManager())
-
def testGetService(self):
- self.createServiceManager()
sm = traverse(self.rootFolder, '++etc++site')
default = traverse(sm, 'default')
@@ -70,7 +61,6 @@
self.assertEqual(testOb, ts)
def test_queryLocalService(self):
- self.createServiceManager()
sm = traverse(self.rootFolder, '++etc++site')
# Test no service case
@@ -97,14 +87,12 @@
def test_get(self):
- self.createServiceManager()
sm = traverse(self.rootFolder, '++etc++site')
default = sm.get('default')
self.assertEqual(default, sm.Packages['default'])
self.assertEqual(sm.get('spam'), None)
def testAddService(self):
- self.createServiceManager()
sm = traverse(self.rootFolder, '++etc++site')
default = traverse(sm, 'default')
@@ -152,15 +140,14 @@
self.testGetService() # set up root localservice
sm=getServiceManager(self.rootFolder)
- self.folder1.setServiceManager(ServiceManager())
- sm2=getServiceManager(self.folder1)
+ sm2 = self.makeSite('folder1')
self.assertEqual(getService(self.folder1, 'test_service'),
sm['default']['test_service1'])
def testComponentArchitectureServiceLookup(self):
- self.rootFolder.setServiceManager(ServiceManager())
- self.folder1.setServiceManager(ServiceManager())
+ self.makeSite()
+ self.makeSite('folder1')
ts = TestService()
@@ -176,8 +163,8 @@
import zope.app.services.tests.sample1
import zope.app.services.tests.sample2
- self.rootFolder.setServiceManager(ServiceManager())
- sm=getServiceManager(self.rootFolder)
+ sm = self.makeSite()
+
default = cw(sm['default'], self.rootFolder, name='default')
default.setObject('m1', Manager())
manager = cw(default['m1'], default, name='m1')
=== Zope3/src/zope/app/services/tests/test_utility.py 1.6 => 1.7 ===
--- Zope3/src/zope/app/services/tests/test_utility.py:1.6 Tue May 27 10:18:25 2003
+++ Zope3/src/zope/app/services/tests/test_utility.py Tue Jun 3 17:43:00 2003
@@ -19,6 +19,7 @@
"""
import unittest
+from zope.app.tests import setup
from zope.app.services.tests import placefulsetup
from zope.app.services import utility
from zope.component.utility import utilityService as globalUtilityService
@@ -33,6 +34,7 @@
from zope.app.interfaces.services.configuration import IUseConfiguration
from zope.app.interfaces.dependable import IDependable
from zope.context import getWrapperContainer
+from zope.app.tests import setup
class IFo(Interface): pass
@@ -84,11 +86,9 @@
class TestUtilityService(placefulsetup.PlacefulSetup, unittest.TestCase):
def setUp(self):
- placefulsetup.PlacefulSetup.setUp(self)
- self.buildFolders()
- sm = placefulsetup.createServiceManager(self.rootFolder)
- placefulsetup.addService(sm, "Utilities",
- utility.LocalUtilityService())
+ sm = placefulsetup.PlacefulSetup.setUp(self, site=True)
+ setup.addService(sm, "Utilities",
+ utility.LocalUtilityService())
def test_queryUtility_delegates_to_global(self):
globalUtilityService.provideUtility(IFoo, Foo("global"))
=== Zope3/src/zope/app/services/tests/test_view.py 1.14 => 1.15 ===
--- Zope3/src/zope/app/services/tests/test_view.py:1.14 Sun Jun 1 11:59:36 2003
+++ Zope3/src/zope/app/services/tests/test_view.py Tue Jun 3 17:43:00 2003
@@ -81,9 +81,7 @@
class TestViewService(PlacefulSetup, TestingIConfigurable, TestCase):
def setUp(self):
- PlacefulSetup.setUp(self)
- self.buildFolders()
- self.rootFolder.setServiceManager(ServiceManager())
+ PlacefulSetup.setUp(self, site=True)
self._service = ContextWrapper(ViewService(), self.rootFolder)
def test_implements_IViewService(self):
@@ -157,11 +155,7 @@
def test_queryView_delegation(self):
service = self._service
- self.buildFolders()
- self.rootFolder.setServiceManager(ServiceManager())
-
- sm = traverse(self.rootFolder, '++etc++site')
-
+ sm = self.buildFolders(site=True)
configure = traverse(sm, 'default').getConfigurationManager()
configuration = Configuration()
configure.setObject('', configuration)
=== Removed File Zope3/src/zope/app/services/tests/servicemanager.py ===