[Zope3-checkins] CVS: Zope3/src/zope/app/browser/container/tests - test_adding.py:1.29

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


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

Modified Files:
	test_adding.py 
Log Message:


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




=== Zope3/src/zope/app/browser/container/tests/test_adding.py 1.28 => 1.29 ===
--- Zope3/src/zope/app/browser/container/tests/test_adding.py:1.28	Fri Mar  5 17:08:53 2004
+++ Zope3/src/zope/app/browser/container/tests/test_adding.py	Tue Mar  9 07:39:04 2004
@@ -15,7 +15,6 @@
 
 $Id$
 """
-
 import unittest
 from zope.testing.doctestunit import DocTestSuite
 from zope.app import zapi
@@ -27,7 +26,6 @@
 from zope.app.interfaces.exceptions import UserError
 from zope.app.interfaces.traversing import IContainmentRoot
 from zope.app.tests.placelesssetup import PlacelessSetup, setUp, tearDown
-from zope.component.factory import provideFactory
 from zope.component.interfaces import IFactory
 from zope.component.exceptions import ComponentLookupError
 from zope.interface import implements, Interface, directlyProvides
@@ -60,6 +58,9 @@
 
     implements(IFactory)
 
+    title = ''
+    description = ''
+
     def getInterfaces(self):
         return ()
 
@@ -113,12 +114,12 @@
 
     def testAction(self):
         # make a private factory
-        provideFactory('fooprivate', Factory())
+        ztapi.provideUtility(IFactory, Factory(), 'fooprivate')
 
         factory = Factory()
         factory.__Security_checker__ = zope.security.checker.NamesChecker(      
             ['__call__'])
-        provideFactory('foo', factory)
+        ztapi.provideUtility(IFactory, factory, 'foo')
 
         container = Container()
         adding = Adding(container, TestRequest())
@@ -211,7 +212,7 @@
     ...     if not isinstance(object, F1):
     ...         raise zope.interface.Invalid()
     >>> def prefactory(container, name, factory):
-    ...     if factory._class is not F1:
+    ...     if factory._callable is not F1:
     ...         raise zope.interface.Invalid()
     >>> pre.factory = prefactory
 
@@ -225,10 +226,9 @@
     >>> class Container:
     ...     zope.interface.implements(IContainer)
 
-    >>> from zope.app.component.classfactory import ClassFactory
-    >>> factoryService = zapi.getService(None, zapi.servicenames.Factories)
-    >>> factoryService.provideFactory('f1', ClassFactory(F1))
-    >>> factoryService.provideFactory('f2', ClassFactory(F2))
+    >>> from zope.component.factory import Factory
+    >>> ztapi.provideUtility(IFactory, Factory(F1), 'f1')
+    >>> ztapi.provideUtility(IFactory, Factory(F2), 'f2')
 
     >>> from zope.app.browser.container.adding import Adding
     >>> adding = Adding(Container(), TestRequest())
@@ -376,7 +376,7 @@
     ...     if not isinstance(object, F1):
     ...         raise zope.interface.Invalid()
     >>> def prefactory(container, name, factory):
-    ...     if factory._class is not F1:
+    ...     if factory._callable is not F1:
     ...         raise zope.interface.Invalid()
     >>> pre.factory = prefactory
 
@@ -390,10 +390,9 @@
     >>> class Container:
     ...     zope.interface.implements(IContainer)
 
-    >>> from zope.app.component.classfactory import ClassFactory
-    >>> factoryService = zapi.getService(None, zapi.servicenames.Factories)
-    >>> factoryService.provideFactory('f1', ClassFactory(F1))
-    >>> factoryService.provideFactory('f2', ClassFactory(F2))
+    >>> from zope.component.factory import Factory
+    >>> ztapi.provideUtility(IFactory, Factory(F1), 'f1')
+    >>> ztapi.provideUtility(IFactory, Factory(F2), 'f2')
 
     >>> from zope.app.browser.container.adding import Adding
     >>> adding = Adding(Container(), TestRequest())
@@ -447,7 +446,7 @@
     ...     if not isinstance(object, F1):
     ...         raise zope.interface.Invalid()
     >>> def prefactory(container, name, factory):
-    ...     if factory._class is not F1:
+    ...     if factory._callable is not F1:
     ...         raise zope.interface.Invalid()
     >>> pre.factory = prefactory
 
@@ -461,10 +460,9 @@
     >>> class Container:
     ...     zope.interface.implements(IContainer)
 
-    >>> from zope.app.component.classfactory import ClassFactory
-    >>> factoryService = zapi.getService(None, zapi.servicenames.Factories)
-    >>> factoryService.provideFactory('f1', ClassFactory(F1))
-    >>> factoryService.provideFactory('f2', ClassFactory(F2))
+    >>> from zope.component.factory import Factory
+    >>> ztapi.provideUtility(IFactory, Factory(F1), 'f1')
+    >>> ztapi.provideUtility(IFactory, Factory(F2), 'f2')
     
     >>> from zope.app.browser.container.adding import Adding
     >>> adding = Adding(Container(), TestRequest())
@@ -518,7 +516,7 @@
     ...     if not isinstance(object, F1):
     ...         raise zope.interface.Invalid()
     >>> def prefactory(container, name, factory):
-    ...     if factory._class is not F1:
+    ...     if factory._callable is not F1:
     ...         raise zope.interface.Invalid()
     >>> pre.factory = prefactory
 




More information about the Zope3-Checkins mailing list