[Zope3-checkins] CVS: Zope3/src/zope/app/schema/tests - test_fieldfactory.py:1.5

Stephan Richter srichter at cosmos.phy.tufts.edu
Tue Mar 9 07:39:42 EST 2004


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

Modified Files:
	test_fieldfactory.py 
Log Message:


Adjusted code to use utility service to look up factories or use the new zapi
methods.




=== Zope3/src/zope/app/schema/tests/test_fieldfactory.py 1.4 => 1.5 ===
--- Zope3/src/zope/app/schema/tests/test_fieldfactory.py:1.4	Wed Mar  3 17:54:27 2004
+++ Zope3/src/zope/app/schema/tests/test_fieldfactory.py	Tue Mar  9 07:39:10 2004
@@ -19,11 +19,11 @@
 
 import zope.app.schema
 
+from zope.app import zapi
 from zope.component.exceptions import ComponentLookupError
+from zope.component.interfaces import IFactory
 from zope.app.tests.placelesssetup import PlacelessSetup
 from zope.security.management import newSecurityManager, system_user
-from zope.component import getService
-from zope.app.services.servicenames import Factories
 from zope.schema.interfaces import IField, IText
 from zope.interface import Interface
 from zope.configuration import xmlconfig
@@ -39,27 +39,23 @@
                                  zope.app.schema)
 
     def testRegisterFields(self):
-        factory = getService(None, Factories).getFactory(
-            'zope.schema._bootstrapfields.Text')
+        factory = zapi.getUtility(None, IFactory,
+                                  'zope.schema._bootstrapfields.Text')
         self.assertEquals(factory.title, "Text Field")
         self.assertEquals(factory.description, "Text Field")
 
     def testGetFactoriesForIField(self):
-        factories = getService(None, Factories).getFactoriesFor(IField)
+        factories = zapi.getFactoriesFor(None, IField)
         self.assertEqual(len(factories), 3)
 
     def testGetFactoriesForIText(self):
-        factories = getService(None, Factories).getFactoriesFor(IText)
+        factories = zapi.getFactoriesFor(None, IText)
         self.assertEqual(len(factories), 2)
 
     def testGetFactoriesUnregistered(self):
-        fservice = getService(None, Factories)
-        self.assertRaises(ComponentLookupError, fservice.getFactoriesFor,
-                          IFoo)
-
-    def testQueryFactoriesUnregistered(self):
-        fservice = getService(None, Factories)
-        self.assertEqual(fservice.queryFactoriesFor(IFoo, None), None)
+        factories = zapi.getFactoriesFor(None, IFoo)
+        self.assertEqual(len(factories), 0)
+
 
 def test_suite():
     suite = unittest.TestSuite()




More information about the Zope3-Checkins mailing list