[Zope3-checkins] CVS: Zope3/src/zope/app/utilities/tests -
test_interfaceutility.py:1.2
Sidnei da Silva
sidnei at x3ng.com.br
Sat Aug 9 15:12:33 EDT 2003
Update of /cvs-repository/Zope3/src/zope/app/utilities/tests
In directory cvs.zope.org:/tmp/cvs-serv17639
Modified Files:
test_interfaceutility.py
Log Message:
Make sure only utilities providing IInterface get in the mix.
=== Zope3/src/zope/app/utilities/tests/test_interfaceutility.py 1.1 => 1.2 ===
--- Zope3/src/zope/app/utilities/tests/test_interfaceutility.py:1.1 Wed Aug 6 17:16:48 2003
+++ Zope3/src/zope/app/utilities/tests/test_interfaceutility.py Sat Aug 9 14:12:28 2003
@@ -42,6 +42,7 @@
from zope.app.tests import setup
from zope.interface.interface import InterfaceClass
from zope.interface.interfaces import IInterface
+from zope.interface import Interface
class IBaz(Interface): pass
@@ -87,7 +88,7 @@
class Foo(InterfaceClass, Baz):
def __init__(self, name):
- InterfaceClass.__init__(self, name)
+ InterfaceClass.__init__(self, name, (Interface,))
Baz.__init__(self, name)
class Bar(Foo): pass
@@ -112,6 +113,42 @@
self.assert_(iface_service != globalInterfaceService)
self.assertEqual(iface_service.getInterface("bob").__class__, Foo)
self.assertEqual(iface_service.getInterface('').__class__, Bar)
+
+ def test_localInterfaceitems_filters_accordingly(self):
+ bar = Bar("global")
+ baz = Baz("global baz")
+ foo = Foo("global bob")
+ globalUtilityService.provideUtility(IInterface, foo,
+ name="bob")
+ globalUtilityService.provideUtility(IInterface, bar)
+ globalUtilityService.provideUtility(IBaz, baz)
+
+ iface_service = getService(self.rootFolder, Interfaces)
+ self.assert_(iface_service != globalInterfaceService)
+ self.assertEqual(iface_service.items(),
+ [('bob', foo), ('', bar)])
+ self.assertEqual(iface_service.items(base=IInterface),
+ [('bob', foo), ('', bar)])
+ self.assertEqual(iface_service.items(base=Interface),
+ [])
+
+ def test_localInterfaceitems_filters_only_interfaces(self):
+ bar = Bar("global")
+ baz = Baz("global baz")
+ foo = Foo("global bob")
+ globalUtilityService.provideUtility(IInterface, foo,
+ name="bob")
+ globalUtilityService.provideUtility(ILocalUtility, bar)
+ globalUtilityService.provideUtility(IBaz, baz)
+
+ iface_service = getService(self.rootFolder, Interfaces)
+ self.assert_(iface_service != globalInterfaceService)
+ self.assertEqual(iface_service.items(base=IInterface),
+ [('bob', foo)])
+ self.assertEqual(iface_service.items(base=ILocalUtility),
+ [('', bar)])
+ self.assertEqual(iface_service.items(base=IBaz),
+ [])
def test_getLocalInterface_raisesComponentLookupError(self):
globalUtilityService.provideUtility(IInterface, Foo("global"))
More information about the Zope3-Checkins
mailing list