[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/intid/tests.py
change ReferenceSetupMixin:
Dominik Huber
dominik.huber at projekt01.ch
Tue Nov 30 15:11:56 EST 2004
Log message for revision 28541:
change ReferenceSetupMixin:
- provide IPersistent to IConnection adaption
like the real zcml registration
add test_localutilityservice_bug test to illustrate
a bug that is caused during registration or unregistration
of a local utitlity service by the intid-utility.
Changed:
U Zope3/trunk/src/zope/app/intid/tests.py
-=-
Modified: Zope3/trunk/src/zope/app/intid/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/intid/tests.py 2004-11-30 12:05:25 UTC (rev 28540)
+++ Zope3/trunk/src/zope/app/intid/tests.py 2004-11-30 20:11:55 UTC (rev 28541)
@@ -48,7 +48,7 @@
from zope.app.keyreference.persistent import KeyReferenceToPersistent
from zope.app.keyreference.interfaces import IKeyReference
self.root = setup.placefulSetUp(site=True)
- ztapi.provideAdapter(ILocation, IConnection, connectionOfPersistent)
+ ztapi.provideAdapter(IPersistent, IConnection, connectionOfPersistent)
ztapi.provideAdapter(IPersistent, IKeyReference,
KeyReferenceToPersistent)
@@ -210,7 +210,42 @@
self.assertEquals(events[0].original_event.object, parent_folder)
self.assertEquals(events[0].object, folder)
+ def test_localutilityservice_bug(self):
+ # setup first some stuff
+ from zope.app.intid import addIntIdSubscriber
+ from zope.app.container.contained import ObjectAddedEvent
+ from zope.app.intid.interfaces import IIntIdAddedEvent
+ parent_folder = self.root['folder1']['folder1_1']
+ folder = self.root['folder1']['folder1_1']['folder1_1_1']
+ events = []
+ ztapi.handle([IIntIdAddedEvent], events.append)
+ setSite(parent_folder)
+ # create a local utility sevice
+ utils = LocalUtilityService()
+ utils.__parent__ = folder # cheat IConnection adapter
+
+ # try to register the local utility sevice
+ self.assertRaises(TypeError, addIntIdSubscriber, utils, ObjectAddedEvent(parent_folder))
+
+ # problem: local utility sevice does not provide IPersistent
+ # -> LocalUtilityService implementsOnly(ILocalUtilityService, ISimpleService, IBindingAware)
+ self.assertEquals(False, IPersistent.providedBy(utils))
+
+ # add IPersistent to utils
+ from zope.interface import directlyProvides, directlyProvidedBy
+ directlyProvides(utils, IPersistent, directlyProvidedBy(utils))
+
+ # try another time...
+ addIntIdSubscriber(utils, ObjectAddedEvent(parent_folder))
+
+ # check that the utilis got registered
+ id = self.utility.getId(utils)
+ id1 = self.utility1.getId(utils)
+ self.assertEquals(len(events), 1)
+ self.assertEquals(events[0].original_event.object, parent_folder)
+ self.assertEquals(events[0].object, utils)
+
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestIntIds))
More information about the Zope3-Checkins
mailing list