[Zope3-checkins] CVS: Zope3/src/zope/app/cache/tests - test_annotationcacheable.py:1.9.6.1

Jim Fulton jim at zope.com
Mon Sep 8 15:22:04 EDT 2003


Update of /cvs-repository/Zope3/src/zope/app/cache/tests
In directory cvs.zope.org:/tmp/cvs-serv20092/src/zope/app/cache/tests

Modified Files:
      Tag: parentgeddon-branch
	test_annotationcacheable.py 
Log Message:
Checking in work in progress on parentgeddon-branch so Fred can help
me to get the tests passing.  Specific log entries will be provided
when we merge this into the head.


=== Zope3/src/zope/app/cache/tests/test_annotationcacheable.py 1.9 => 1.9.6.1 ===
--- Zope3/src/zope/app/cache/tests/test_annotationcacheable.py:1.9	Tue Aug 19 13:34:12 2003
+++ Zope3/src/zope/app/cache/tests/test_annotationcacheable.py	Mon Sep  8 14:21:33 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
+from zope.app.services.servicenames import Adapters, Utilities
 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
+from zope.app.interfaces.cache import ICachingService, ICache
 from zope.component.service import serviceManager as sm
 from zope.app.interfaces.services.service import ISimpleService
 from zope.interface import implements
@@ -39,26 +39,12 @@
     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()
@@ -73,8 +59,9 @@
     def testInvalidate(self):
         # Test that setting a different cache ID invalidates the old cached
         # value
-        self.service.caches['cache1'] = cache1 = CacheStub()
-        self.service.caches['cache2'] = cache2 = CacheStub()
+        utilities = getService(None, Utilities)
+        utilities.provideUtility(ICache, CacheStub(), 'cache1')
+        utilities.provideUtility(ICache, CacheStub(), 'cache2')
         ob = ObjectStub()
         adapter = AnnotationCacheable(ob)
         adapter.setCacheId('cache1')




More information about the Zope3-Checkins mailing list