Skip to content

Commit

Permalink
Some provideUtility -> registerUtility conversion to cut down the
Browse files Browse the repository at this point in the history
deprecation noise a bit.
  • Loading branch information
philikon committed Apr 4, 2006
1 parent 1b75c38 commit e90eb00
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions tests/test_interfaceutility.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ def setUp(self):

def test_getLocalInterface_delegates_to_globalUtility(self):
gsm = zapi.getGlobalSiteManager()
gsm.provideUtility(IInterface, Bar("blob"), name="blob")
gsm.provideUtility(IBaz, Baz("global baz"))
gsm.provideUtility(IInterface, Foo("global bob"), name="bob")
gsm.registerUtility(Bar("blob"), IInterface, name="blob")
gsm.registerUtility(Baz("global baz"), IBaz)
gsm.registerUtility(Foo("global bob"), IInterface, name="bob")

self.assertEqual(getInterface(None, "bob").__class__, Foo)
self.assertEqual(getInterface(None, "blob").__class__, Bar)
Expand All @@ -102,9 +102,9 @@ def test_localInterfaceitems_filters_accordingly(self):
foo = Foo("global bob")

gsm = zapi.getGlobalSiteManager()
gsm.provideUtility(IInterface, foo, name="bob")
gsm.provideUtility(IInterface, bar)
gsm.provideUtility(IBaz, baz)
gsm.registerUtility(foo, IInterface, name="bob")
gsm.registerUtility(bar, IInterface)
gsm.registerUtility(baz, IBaz)

ifaces = searchInterface(None)
self.assert_(len(ifaces), 2)
Expand All @@ -126,9 +126,10 @@ def test_localInterfaceitems_filters_only_interfaces(self):
baz = Baz("global baz")
foo = Foo("global bob")
gsm = zapi.getGlobalSiteManager()
gsm.provideUtility(IInterface, foo, name="bob")
gsm.provideUtility(ILocalUtility, bar)
gsm.provideUtility(IBaz, baz)

gsm.registerUtility(foo, IInterface, name="bob")
gsm.registerUtility(bar, ILocalUtility)
gsm.registerUtility(baz, IBaz)

iface_utilities = gsm.getUtilitiesFor(IInterface)
ifaces = [iface for (name, iface) in iface_utilities]
Expand All @@ -144,9 +145,9 @@ def test_localInterfaceitems_filters_only_interfaces(self):

def test_getLocalInterface_raisesComponentLookupError(self):
gsm = zapi.getGlobalSiteManager()
gsm.provideUtility(IInterface, Foo("global"))
gsm.provideUtility(IBaz, Baz("global baz"))
gsm.provideUtility(IInterface, Foo("global bob"), name="bob")
gsm.registerUtility(Foo("global"), Interface)
gsm.registerUtility(Baz("global baz"), IBaz)
gsm.registerUtility(Foo("global bob"), IInterface, name="bob")

self.assertRaises(ComponentLookupError,
getInterface, None, "bobesponja")
Expand All @@ -156,9 +157,9 @@ def test_globalsearchInterface_delegates_to_globalUtility(self):
bar = Bar("global")
baz = Baz("global baz")
gsm = zapi.getGlobalSiteManager()
gsm.provideUtility(IInterface, bar)
gsm.provideUtility(IBaz, baz)
gsm.provideUtility(IInterface, foo, name="bob")
gsm.registerUtility(foo, IInterface, name="bob")
gsm.registerUtility(bar, IInterface)
gsm.registerUtility(baz, IBaz)

self.assertEqual(searchInterface(None, search_string="bob"),
[foo])
Expand All @@ -169,9 +170,9 @@ def test_localsearchInterface_delegates_to_globalUtility(self):
bar = Bar("global")
baz = Baz("global baz")
gsm = zapi.getGlobalSiteManager()
gsm.provideUtility(IInterface, bar)
gsm.provideUtility(IBaz, baz)
gsm.provideUtility(IInterface, foo, name="bob")
gsm.registerUtility(foo, IInterface, name="bob")
gsm.registerUtility(bar, IInterface)
gsm.registerUtility(baz, IBaz)

self.assertEqual(searchInterface(None, search_string="bob"),
[foo])
Expand All @@ -192,8 +193,8 @@ def test_query_get_Utility_delegates_to_global(self):

def test_local_utilities(self):
gsm = zapi.getGlobalSiteManager()
gsm.provideUtility(IInterface, Foo("global"))
gsm.provideUtility(IInterface, Foo("global bob"), name="bob")
gsm.registerUtility(Foo("global"), IInterface)
gsm.registerUtility(Foo("global bob"), IInterface, name="bob")

sm = zapi.getSiteManager(self.rootFolder)
default = traverse(self.rootFolder, "++etc++site/default")
Expand Down

0 comments on commit e90eb00

Please sign in to comment.