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

Jim Fulton cvs-admin at zope.org
Fri Nov 21 12:12:25 EST 2003


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

Modified Files:
	test_adding.py test_contents.py 
Log Message:
Changed to use the new ztapi module, which provides handy functions
for setting up adapters and views for tests.  This is needed because
there are no-longer global adapter and view services sitting around as
module globals.


=== Zope3/src/zope/app/browser/container/tests/test_adding.py 1.11 => 1.12 ===
--- Zope3/src/zope/app/browser/container/tests/test_adding.py:1.11	Sun Sep 21 13:30:25 2003
+++ Zope3/src/zope/app/browser/container/tests/test_adding.py	Fri Nov 21 12:11:54 2003
@@ -18,6 +18,7 @@
 
 from unittest import TestCase, main, makeSuite
 from zope.app import zapi
+from zope.app.tests import ztapi
 from zope.app.browser.absoluteurl import AbsoluteURL
 from zope.app.browser.container.adding import Adding
 from zope.app.event.tests.placelesssetup import getEvents
@@ -27,13 +28,11 @@
 from zope.app.interfaces.exceptions import UserError
 from zope.app.interfaces.traversing import IContainmentRoot
 from zope.app.tests.placelesssetup import PlacelessSetup
-from zope.component.view import provideView
 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
 from zope.publisher.browser import TestRequest, BrowserView
-from zope.publisher.interfaces.browser import IBrowserPresentation
 from zope.app.container.contained import contained
 import zope.security.checker
 from zope.exceptions import ForbiddenAttribute
@@ -87,7 +86,7 @@
         container = Container()
         request = TestRequest()
         adding = Adding(container, request)
-        provideView(IAdding, "Thing", IBrowserPresentation, CreationView)
+        ztapi.browserView(IAdding, "Thing", CreationView)
         self.assertEqual(adding.contentName, None)
         view = adding.publishTraverse(request, 'Thing=foo')
         self.assertEqual(view.action(), 'been there, done that')
@@ -104,7 +103,7 @@
         container = Container()
         request = TestRequest()
         adding = Adding(container, request)
-        provideView(IAdding, "Thing", IBrowserPresentation, CreationView)
+        ztapi.browserView(IAdding, "Thing", CreationView)
 
         self.assertEqual(adding.contentName, None)
         view = adding.publishTraverse(request, 'Thing=')
@@ -166,9 +165,8 @@
         request = TestRequest()
         adding = Adding(container, request)
         adding.__name__ = '+'
-        provideView(IAdding, "Thing", IBrowserPresentation, CreationView)
-        provideView(Interface, "absolute_url", IBrowserPresentation,
-                    AbsoluteURL)
+        ztapi.browserView(IAdding, "Thing", CreationView)
+        ztapi.browserView(Interface, "absolute_url", AbsoluteURL)
         self.assertRaises(UserError, adding.action, '', 'foo')
         self.assertRaises(UserError, adding.action, 'Unknown', '')
         adding.action('Thing', 'foo')


=== Zope3/src/zope/app/browser/container/tests/test_contents.py 1.25 => 1.26 ===
--- Zope3/src/zope/app/browser/container/tests/test_contents.py:1.25	Sun Sep 21 13:30:29 2003
+++ Zope3/src/zope/app/browser/container/tests/test_contents.py	Fri Nov 21 12:11:54 2003
@@ -18,9 +18,9 @@
 """
 
 from unittest import TestCase, TestSuite, main, makeSuite
+from zope.app.tests import ztapi
 from zope.app.services.tests.placefulsetup import PlacefulSetup
 from zope.app.tests.placelesssetup import PlacelessSetup
-from zope.component.adapter import provideAdapter
 
 from zope.app.interfaces.container import IContainer
 from zope.app.interfaces.copypastemove import IObjectMover
@@ -60,10 +60,12 @@
     def setUp(self):
         PlacefulSetup.setUp(self)
         PlacefulSetup.buildFolders(self)
-        provideAdapter(None, IObjectCopier, ObjectCopier)
-        provideAdapter(None, IObjectMover, ObjectMover)
+        
+        ztapi.provideAdapter(None, IObjectCopier, ObjectCopier)
+        ztapi.provideAdapter(None, IObjectMover, ObjectMover)
 
-        provideAdapter(IAnnotations, IPrincipalClipboard, PrincipalClipboard)
+        ztapi.provideAdapter(IAnnotations, IPrincipalClipboard,
+                             PrincipalClipboard)
         root_sm = getServiceManager(None)
         svc = PrincipalAnnotationService()
         root_sm.defineService("PrincipalAnnotation", \
@@ -111,8 +113,7 @@
             created = datetime(2001, 1, 1, 1, 1, 1)
             modified = datetime(2002, 2, 2, 2, 2, 2)
 
-        from zope.component.adapter import provideAdapter
-        provideAdapter(IDocument, IZopeDublinCore, FauxDCAdapter)
+        ztapi.provideAdapter(IDocument, IZopeDublinCore, FauxDCAdapter)
 
         fc = self._TestView__newView(container)
         info = fc.listContentInfo()[0]
@@ -170,10 +171,11 @@
     def setUp(self):
         PlacefulSetup.setUp(self)
         PlacefulSetup.buildFolders(self)
-        provideAdapter(None, IObjectCopier, ObjectCopier)
-        provideAdapter(None, IObjectMover, ObjectMover)
+        ztapi.provideAdapter(None, IObjectCopier, ObjectCopier)
+        ztapi.provideAdapter(None, IObjectMover, ObjectMover)
 
-        provideAdapter(IAnnotations, IPrincipalClipboard, PrincipalClipboard)
+        ztapi.provideAdapter(IAnnotations, IPrincipalClipboard,
+                             PrincipalClipboard)
         root_sm = getServiceManager(None)
         svc = PrincipalAnnotationService()
         root_sm.defineService("PrincipalAnnotation", \




More information about the Zope3-Checkins mailing list