[Zope3-checkins] CVS: Zope3/src/zope/app/services/tests - test_auth.py:1.17 test_cacheconfiguration.py:1.13 test_cachingservice.py:1.11 test_configurationmanager.py:1.10 test_connectionconfiguration.py:1.14 test_connectionservice.py:1.11 test_eventservice.py:1.26 test_pagefolder.py:1.5 test_serviceconfiguration.py:1.12 test_servicemanager.py:1.12
Steve Alexander
steve@cat-box.net
Thu, 5 Jun 2003 08:03:49 -0400
Update of /cvs-repository/Zope3/src/zope/app/services/tests
In directory cvs.zope.org:/tmp/cvs-serv15171/src/zope/app/services/tests
Modified Files:
test_auth.py test_cacheconfiguration.py test_cachingservice.py
test_configurationmanager.py test_connectionconfiguration.py
test_connectionservice.py test_eventservice.py
test_pagefolder.py test_serviceconfiguration.py
test_servicemanager.py
Log Message:
Placeful setup for tests now sets up a ZopeContainerDecorator.
This means that in such tests, you no longer need to use
ZopeContainerAdapter to get the correct events issued, and perform context-
wrapping duties, when you use a container.
However, it does mean that your tests need to expect these events and
context-wrappers to be used.
=== Zope3/src/zope/app/services/tests/test_auth.py 1.16 => 1.17 ===
--- Zope3/src/zope/app/services/tests/test_auth.py:1.16 Tue Jun 3 18:46:22 2003
+++ Zope3/src/zope/app/services/tests/test_auth.py Thu Jun 5 08:03:18 2003
@@ -57,7 +57,7 @@
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.12 => 1.13 ===
--- Zope3/src/zope/app/services/tests/test_cacheconfiguration.py:1.12 Tue Jun 3 18:46:22 2003
+++ Zope3/src/zope/app/services/tests/test_cacheconfiguration.py Thu Jun 5 08:03:18 2003
@@ -18,7 +18,6 @@
__metaclass__ = type
from unittest import TestCase, main, makeSuite
-from zope.app.container.zopecontainer import ZopeContainerAdapter
from zope.app.context import ContextWrapper
from zope.app.interfaces.cache.cache import ICache
from zope.app.interfaces.cache.cache import ICachingService
@@ -34,10 +33,11 @@
from zope.app.tests import setup
from zope.app.traversing import traverse
from zope.context import ContextMethod
+from zope.interface import implements
class DependableStub:
- __implements__ = IDependable
+ implements(IDependable)
def addDependent(self, location):
pass
@@ -51,7 +51,7 @@
class TestCache(DependableStub):
- __implements__ = ICache, IDependable, IAttributeUseConfigurable
+ implements(ICache, IAttributeUseConfigurable)
def invalidateAll(self):
self.invalidated = True
@@ -59,8 +59,7 @@
class CachingServiceStub(DependableStub):
- __implements__ = (ICachingService, IConfigurable, IDependable,
- IAttributeUseConfigurable, ILocalService)
+ implements(ICachingService, IConfigurable, ILocalService)
def __init__(self):
self.bindings = {}
@@ -109,7 +108,7 @@
self.default.setObject('cch', TestCache())
self.cch = traverse(self.default, 'cch')
- self.cm = ZopeContainerAdapter(self.default.getConfigurationManager())
+ self.cm = self.default.getConfigurationManager()
key = self.cm.setObject('',
CacheConfiguration('cache_name',
'/++etc++site/default/cch'))
=== Zope3/src/zope/app/services/tests/test_cachingservice.py 1.10 => 1.11 ===
--- Zope3/src/zope/app/services/tests/test_cachingservice.py:1.10 Tue Jun 3 17:43:00 2003
+++ Zope3/src/zope/app/services/tests/test_cachingservice.py Thu Jun 5 08:03:18 2003
@@ -26,6 +26,7 @@
from zope.app.interfaces.services.configuration import Active, Registered
from zope.app.services.tests.eventsetup import EventSetup
from zope.app.traversing import getPath, traverse
+from zope.app.interfaces.annotation import IAttributeAnnotatable
def sort(list):
list.sort()
@@ -33,7 +34,7 @@
class CacheStub:
- implements(ICache)
+ implements(ICache, IAttributeAnnotatable)
def __init__(self, name):
self.name = name
@@ -54,19 +55,16 @@
return service
- def addCache(self, name, cache=None, cname=None, status=Active,
- folder=''):
+ def addCache(self, name, cache=None, cname=None, status=Active, folder=''):
if not cache:
cache = CacheStub("%s/%s" % (folder, name))
if not cname:
cname = name
- default = traverse(self.rootFolder,
- folder +'/++etc++site/default')
+ default = traverse(self.rootFolder, folder +'/++etc++site/default')
key = default.setObject(cname, cache)
cache = traverse(default, key)
configure = default.getConfigurationManager()
- key = configure.setObject('',
- CacheConfiguration(name, getPath(cache)))
+ key = configure.setObject('', CacheConfiguration(name, getPath(cache)))
traverse(configure, key).status = status
return cache
=== Zope3/src/zope/app/services/tests/test_configurationmanager.py 1.9 => 1.10 ===
--- Zope3/src/zope/app/services/tests/test_configurationmanager.py:1.9 Tue Jun 3 17:43:00 2003
+++ Zope3/src/zope/app/services/tests/test_configurationmanager.py Thu Jun 5 08:03:18 2003
@@ -16,7 +16,6 @@
"""
from unittest import TestCase, main, makeSuite
-from zope.app.container.zopecontainer import ZopeContainerAdapter
from zope.app.interfaces.container import IContainer
from zope.app.interfaces.container import IDeleteNotifiable
from zope.app.interfaces.container import IZopeContainer
@@ -28,18 +27,17 @@
from zope.component.adapter import provideAdapter
from zope.interface.common.tests.basemapping import BaseTestIEnumerableMapping
from zope.interface.verify import verifyObject
-
+from zope.interface import implements
class Undeletable:
- __implements__ = IDeleteNotifiable
+ implements(IDeleteNotifiable)
def beforeDeleteHook(self, object, container):
self.was_called = 1
class Test(BaseTestIEnumerableMapping, PlacelessSetup, TestCase):
-
"""Testing for Configuration Manager """
def setUp(self):
@@ -334,7 +332,6 @@
#########################################################
def test_manageBeforeDelete(self):
- provideAdapter(IContainer, IZopeContainer, ZopeContainerAdapter)
container = []
manager = ConfigurationManager()
thingy = Undeletable()
@@ -367,7 +364,6 @@
default.__delitem__, 'configuration')
default.setObject('xxx', ConfigurationManager())
del default['RegistrationManager']
-
def test_suite():
=== Zope3/src/zope/app/services/tests/test_connectionconfiguration.py 1.13 => 1.14 ===
--- Zope3/src/zope/app/services/tests/test_connectionconfiguration.py:1.13 Tue Jun 3 18:46:22 2003
+++ Zope3/src/zope/app/services/tests/test_connectionconfiguration.py Thu Jun 5 08:03:18 2003
@@ -21,7 +21,6 @@
from zope.app.services.connection import ConnectionConfiguration
from zope.app.services.tests.placefulsetup import PlacefulSetup
from zope.app.traversing import traverse
-from zope.app.container.zopecontainer import ZopeContainerAdapter
from zope.app.interfaces.services.configuration import Active, Unregistered
from zope.app.interfaces.rdb import IZopeDatabaseAdapter
from zope.app.interfaces.dependable import IDependable
@@ -34,10 +33,11 @@
import IAttributeUseConfigurable, IUseConfiguration
from zope.app.tests import setup
from zope.app.interfaces.services.service import ILocalService
+from zope.interface import implements
class DependableStub:
- __implements__ = IDependable
+ implements(IDependable)
def addDependent(self, location):
pass
@@ -51,7 +51,7 @@
class TestDA(DependableStub):
- __implements__ = IZopeDatabaseAdapter, IDependable, IUseConfiguration
+ implements(IZopeDatabaseAdapter, IDependable, IUseConfiguration)
def addUsage(self, location):
pass
@@ -59,8 +59,8 @@
class ConnectionServiceStub(DependableStub):
- __implements__ = (IConnectionService, IConfigurable, IDependable,
- IAttributeUseConfigurable, ILocalService)
+ implements(IConnectionService, IConfigurable, IDependable,
+ IAttributeUseConfigurable, ILocalService)
def __init__(self):
self.bindings = {}
@@ -99,7 +99,7 @@
self.default.setObject('da', TestDA())
self.da = traverse(self.default, 'da')
- self.cm = ZopeContainerAdapter(self.default.getConfigurationManager())
+ self.cm = self.default.getConfigurationManager()
key = self.cm.setObject('',
ConnectionConfiguration('conn_name',
'/++etc++site/default/da'))
=== Zope3/src/zope/app/services/tests/test_connectionservice.py 1.10 => 1.11 ===
--- Zope3/src/zope/app/services/tests/test_connectionservice.py:1.10 Tue Jun 3 18:46:22 2003
+++ Zope3/src/zope/app/services/tests/test_connectionservice.py Thu Jun 5 08:03:18 2003
@@ -17,7 +17,6 @@
import unittest
-from zope.app.container.zopecontainer import ZopeContainerAdapter
from zope.app.interfaces.annotation import IAttributeAnnotatable
from zope.app.interfaces.rdb import IZopeDatabaseAdapter
from zope.app.interfaces.services.configuration import Active, Registered
@@ -28,15 +27,15 @@
from zope.app.services.tests.placefulsetup import PlacefulSetup
from zope.app.tests import setup
from zope.app import zapi
+from zope.interface import implements
class ConnectionServiceForTests(ConnectionService):
- __implements__ = (ConnectionService.__implements__,
- IAttributeUseConfigurable)
+ implements(IAttributeUseConfigurable)
class DAStub:
- __implements__ = IZopeDatabaseAdapter, IAttributeAnnotatable
+ implements(IZopeDatabaseAdapter, IAttributeAnnotatable)
def __init__(self, n):
self.n = n
@@ -61,7 +60,7 @@
self.default.setObject('da1', DAStub(1))
self.default.setObject('da2', DAStub(2))
- self.cm = ZopeContainerAdapter(self.default.getConfigurationManager())
+ self.cm = self.default.getConfigurationManager()
k = self.cm.setObject('', ConnectionConfiguration('conn1',
'/++etc++site/default/da1'))
@@ -82,8 +81,8 @@
default1 = zapi.traverse(sm, 'default')
default1.setObject('da3', DAStub(3))
default1.setObject('da4', DAStub(4))
-
- cm1 = ZopeContainerAdapter(default1.getConfigurationManager())
+
+ cm1 = default1.getConfigurationManager()
k = cm1.setObject('', ConnectionConfiguration('conn1',
'/folder1/++etc++site/default/da3'))
=== Zope3/src/zope/app/services/tests/test_eventservice.py 1.25 => 1.26 ===
--- Zope3/src/zope/app/services/tests/test_eventservice.py:1.25 Tue Jun 3 18:46:22 2003
+++ Zope3/src/zope/app/services/tests/test_eventservice.py Thu Jun 5 08:03:18 2003
@@ -256,14 +256,20 @@
self.assertEqual(self.folder1Subscriber.notified, 0)
self.assertEqual(self.folder1_1Subscriber.notified, 1)
- # Now, put folder1Subscriber back. It should not be notified
- # now, because it was removed as a bad subscriber.
+ # Now, put folder1Subscriber back. This incidentally fires off a
+ # ObjectAddedEvent, since self.folder1 is decorated with a context
+ # decorator.
self.folder1.setObject('folder1Subscriber', folder1Subscriber)
-
- publish(self.folder1, ObjectAddedEvent(None, '/foo'))
self.assertEqual(self.rootFolderSubscriber.notified, 2)
self.assertEqual(self.folder1Subscriber.notified, 0)
self.assertEqual(self.folder1_1Subscriber.notified, 2)
+
+ # folder1Subscriber should not be notified now, because it was removed
+ # as a bad subscriber.
+ publish(self.folder1, ObjectAddedEvent(None, '/foo'))
+ self.assertEqual(self.rootFolderSubscriber.notified, 3)
+ self.assertEqual(self.folder1Subscriber.notified, 0)
+ self.assertEqual(self.folder1_1Subscriber.notified, 3)
def testByPathExplicit(self):
# test complex interaction, with hubids available but explicitly
=== Zope3/src/zope/app/services/tests/test_pagefolder.py 1.4 => 1.5 ===
--- Zope3/src/zope/app/services/tests/test_pagefolder.py:1.4 Tue Jun 3 17:43:00 2003
+++ Zope3/src/zope/app/services/tests/test_pagefolder.py Thu Jun 5 08:03:18 2003
@@ -19,7 +19,9 @@
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.services.pagefolder import PageFolder, PageFolderContextDecorator
+from zope.app.interfaces.services.pagefolder import IPageFolder
+from zope.app.interfaces.context import IZopeContextWrapper
from zope.app.traversing import traverse
from zope.app.services.zpt import ZPTTemplate
from zope.app.services.view import ViewService
@@ -28,15 +30,18 @@
from zope.publisher.interfaces.browser import IBrowserPresentation
from zope.app.services.tests.test_configurationmanager \
import ConfigurationManagerContainerTests
+from zope.component.adapter import provideAdapter
-class I(Interface): pass
+class I(Interface):
+ pass
class Test(ConfigurationManagerContainerTests, PlacefulSetup, TestCase):
def test_setObject(self):
+ provideAdapter(IPageFolder, IZopeContextWrapper,
+ PageFolderContextDecorator)
sm = self.buildFolders(site=True)
setup.addService(sm, 'Views', ViewService(), suffix='service')
-
default = traverse(self.rootFolder, '++etc++site/default')
default.setObject('Views', PageFolder())
=== Zope3/src/zope/app/services/tests/test_serviceconfiguration.py 1.11 => 1.12 ===
--- Zope3/src/zope/app/services/tests/test_serviceconfiguration.py:1.11 Tue Jun 3 18:46:22 2003
+++ Zope3/src/zope/app/services/tests/test_serviceconfiguration.py Thu Jun 5 08:03:18 2003
@@ -20,7 +20,7 @@
from unittest import TestCase, main, makeSuite
-from zope.interface import Interface
+from zope.interface import Interface, implements
from zope.component import getServiceManager, getAdapter
from zope.app.traversing import traverse, getPath
@@ -36,14 +36,12 @@
from zope.app.interfaces.dependable import IDependable
from zope.app.interfaces.dependable import DependencyError
-from zope.app.container.zopecontainer import ZopeContainerAdapter
-
class ITestService(Interface):
pass
class TestServiceBase:
- __implements__ = (ITestService, IBindingAware, IDependable)
+ implements(ITestService, IBindingAware, IDependable)
_bound = _unbound = ()
@@ -71,7 +69,7 @@
return self._dependents
class TestService(TestServiceBase):
- __implements__ = TestServiceBase.__implements__, ISimpleService
+ implements(ISimpleService)
class Test(PlacefulSetup, TestCase):
@@ -91,7 +89,7 @@
'test_service', '/++etc++site/default/c')
self.__c = traverse(default, 'c')
- self.__cm = ZopeContainerAdapter(default.getConfigurationManager())
+ self.__cm = default.getConfigurationManager()
self.__cm.setObject('', configuration)
=== Zope3/src/zope/app/services/tests/test_servicemanager.py 1.11 => 1.12 ===
--- Zope3/src/zope/app/services/tests/test_servicemanager.py:1.11 Tue Jun 3 17:43:00 2003
+++ Zope3/src/zope/app/services/tests/test_servicemanager.py Thu Jun 5 08:03:18 2003
@@ -18,7 +18,7 @@
"""
from unittest import TestCase, TestLoader, TextTestRunner
-from zope.interface import Interface
+from zope.interface import Interface, implements
from zope.context import getWrapperContainer
from zope.app.services.service import ServiceManager
from zope.app.services.service import ServiceConfiguration
@@ -28,13 +28,13 @@
from zope.app.interfaces.services.configuration import Active, Unregistered
from zope.app.interfaces.services.configuration import Registered
from zope.component.service import serviceManager
+from zope.app.interfaces.annotation import IAttributeAnnotatable
class ITestService(Interface):
pass
class TestService:
-
- __implements__ = ITestService
+ implements(ITestService, IAttributeAnnotatable)
class ServiceManagerTests(PlacefulSetup, TestCase):