[Zope3-checkins] CVS: Zope3/src/zope/app/cache/tests -
test_annotationcacheable.py:1.9.6.2
Jim Fulton
jim at zope.com
Mon Sep 8 19:37:22 EDT 2003
Update of /cvs-repository/Zope3/src/zope/app/cache/tests
In directory cvs.zope.org:/tmp/cvs-serv31668/src/zope/app/cache/tests
Modified Files:
Tag: parentgeddon-branch
test_annotationcacheable.py
Log Message:
got more tests to pass
=== Zope3/src/zope/app/cache/tests/test_annotationcacheable.py 1.9.6.1 => 1.9.6.2 ===
--- Zope3/src/zope/app/cache/tests/test_annotationcacheable.py:1.9.6.1 Mon Sep 8 14:21:33 2003
+++ Zope3/src/zope/app/cache/tests/test_annotationcacheable.py Mon Sep 8 18:36:51 2003
@@ -18,12 +18,12 @@
from unittest import TestCase, TestSuite, main, makeSuite
from zope.app.tests.placelesssetup import PlacelessSetup
from zope.component import getService
-from zope.app.services.servicenames import Adapters, Utilities
+from zope.app.services.servicenames import Adapters
from zope.app.interfaces.annotation import IAnnotations
from zope.app.interfaces.annotation import IAttributeAnnotatable
from zope.app.attributeannotations import AttributeAnnotations
from zope.app.cache.annotationcacheable import AnnotationCacheable
-from zope.app.interfaces.cache import ICachingService, ICache
+from zope.app.interfaces.cache import ICachingService
from zope.component.service import serviceManager as sm
from zope.app.interfaces.services.service import ISimpleService
from zope.interface import implements
@@ -39,12 +39,26 @@
def invalidate(self, obj):
self.invalidated.append(obj)
+
+class CachingServiceStub:
+ implements(ICachingService, ISimpleService)
+
+ def __init__(self):
+ self.caches = {}
+
+ def getCache(self, name):
+ return self.caches[name]
+
+
class TestAnnotationCacheable(PlacelessSetup, TestCase):
def setUp(self):
PlacelessSetup.setUp(self)
getService(None, Adapters).provideAdapter(
IAttributeAnnotatable, IAnnotations,
AttributeAnnotations)
+ self.service = CachingServiceStub()
+ sm.defineService('Caching', ICachingService)
+ sm.provideService('Caching', self.service)
def testNormal(self):
ob = ObjectStub()
@@ -59,9 +73,8 @@
def testInvalidate(self):
# Test that setting a different cache ID invalidates the old cached
# value
- utilities = getService(None, Utilities)
- utilities.provideUtility(ICache, CacheStub(), 'cache1')
- utilities.provideUtility(ICache, CacheStub(), 'cache2')
+ self.service.caches['cache1'] = cache1 = CacheStub()
+ self.service.caches['cache2'] = cache2 = CacheStub()
ob = ObjectStub()
adapter = AnnotationCacheable(ob)
adapter.setCacheId('cache1')
More information about the Zope3-Checkins
mailing list