[Zope3-checkins]
SVN: Zope3/branches/jim-index/src/zope/app/catalog/tests.py
Added a UniqueIdUtility stub to the tests.
Gintautas Miliauskas
gintas at pov.lt
Sat Jun 12 05:57:56 EDT 2004
Log message for revision 25377:
Added a UniqueIdUtility stub to the tests.
-=-
Modified: Zope3/branches/jim-index/src/zope/app/catalog/tests.py
===================================================================
--- Zope3/branches/jim-index/src/zope/app/catalog/tests.py 2004-06-12 09:03:00 UTC (rev 25376)
+++ Zope3/branches/jim-index/src/zope/app/catalog/tests.py 2004-06-12 09:57:55 UTC (rev 25377)
@@ -38,17 +38,11 @@
### from zope.app.servicenames import HubIds
from BTrees.IIBTree import IISet
-### from zope.app.index.tests.test_objectretrievingprocessor import FakeObjectHub
-
-### import zope.app.hub as Hub
-
#XXX XXX XXX these will need to be changed XXX XXX XXX
### regEvt = Hub.ObjectRegisteredHubEvent
### unregEvt = Hub.ObjectUnregisteredHubEvent
### modEvt = Hub.ObjectModifiedHubEvent
-#XXX XXX XXX this will probably need to be reimplemented XXX XXX XXX
-class CFakeObjectHub: pass
#class CFakeObjectHub(FakeObjectHub):
# def iterObjectRegistrations(self):
# def gen(things):
@@ -57,7 +51,37 @@
# yield loc,hubid,obj
# return gen(self.data.items())
+class UniqueIdUtilityStub:
+ """A stub for UniqueIdUtility."""
+ def __init__(self):
+ self.ids = {}
+ self.objs = {}
+ self.lastid = 0
+ def _generateId(self):
+ self.lastid += 1
+ return self.lastid
+
+ def register(self, ob):
+ if ob not in self.ids:
+ uid = self._generateId(self)
+ self.ids[ob] = uid
+ self.objs[uid] = ob
+ else:
+ return self.ids[ob]
+
+ def unregister(self, ob):
+ uid = self.ids[ob]
+ del self.ids[ob]
+ del self.objs[id]
+
+ def getObject(self, uid):
+ return self.objs[uid]
+
+ def getId(self, ob):
+ return self.ids[ob]
+
+
class StubIndex:
implements(ISimpleQuery, ICatalogIndex, IUIFieldCatalogIndex)
### implements (ISubscriber)
More information about the Zope3-Checkins
mailing list