[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/form/browser/tests/test_ Use ztapi instead of homecooked functions.

Stephan Richter srichter at cosmos.phy.tufts.edu
Fri Sep 17 12:16:14 EDT 2004


Log message for revision 27588:
  
  Use ztapi instead of homecooked functions.
  
  


Changed:
  U   Zope3/trunk/src/zope/app/form/browser/tests/test_choicecollections.py
  U   Zope3/trunk/src/zope/app/form/browser/tests/test_choicewidget.py
  U   Zope3/trunk/src/zope/app/form/browser/tests/test_directives.py
  U   Zope3/trunk/src/zope/app/form/browser/tests/test_vocabularyquery.py


-=-
Modified: Zope3/trunk/src/zope/app/form/browser/tests/test_choicecollections.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/tests/test_choicecollections.py	2004-09-17 16:16:12 UTC (rev 27587)
+++ Zope3/trunk/src/zope/app/form/browser/tests/test_choicecollections.py	2004-09-17 16:16:14 UTC (rev 27588)
@@ -22,6 +22,7 @@
 from zope.schema import Choice, List
 
 from zope.app import zapi
+from zope.app.tests import ztapi
 from zope.app.tests.placelesssetup import PlacelessSetup
 from zope.app.form.interfaces import IInputWidget, IDisplayWidget
 from zope.app.form.browser import CollectionDisplayWidget
@@ -30,20 +31,13 @@
 from zope.app.form.browser import ChoiceCollectionInputWidget
 from zope.app.form.browser import ItemsMultiDisplayWidget, SelectWidget
 
-
-def provideMultiView(for_, factory, providing, name='', layer="default"):
-    s = zapi.getGlobalService(zapi.servicenames.Presentation)
-    return s.provideAdapter(IBrowserRequest, factory, name, for_,
-                            providing, layer)
-
-
 class ListOfChoicesWidgetTest(PlacelessSetup, unittest.TestCase):
 
     def test_ListOfChoicesDisplayWidget(self):
-        provideMultiView((IList, IChoice),
-                         ChoiceCollectionDisplayWidget, IDisplayWidget)
-        provideMultiView((IList, IIterableVocabulary),
-                         ItemsMultiDisplayWidget, IDisplayWidget)
+        ztapi.provideMultiView((IList, IChoice), IBrowserRequest,
+                         IDisplayWidget, '', ChoiceCollectionDisplayWidget)
+        ztapi.provideMultiView((IList, IIterableVocabulary), IBrowserRequest,
+                         IDisplayWidget, '', ItemsMultiDisplayWidget)
         field = List(value_type=Choice(values=[1, 2, 3]))
         bound = field.bind(object())
         widget = CollectionDisplayWidget(bound, TestRequest())
@@ -53,10 +47,10 @@
 
 
     def test_ChoiceSequenceEditWidget(self):
-        provideMultiView((IList, IChoice),
-                         ChoiceCollectionInputWidget, IInputWidget)
-        provideMultiView((IList, IIterableVocabulary),
-                         SelectWidget, IInputWidget)
+        ztapi.provideMultiView((IList, IChoice), IBrowserRequest,
+                               IInputWidget, '', ChoiceCollectionInputWidget)
+        ztapi.provideMultiView((IList, IIterableVocabulary), IBrowserRequest,
+                               IInputWidget, '', SelectWidget)
         field = List(value_type=Choice(values=[1, 2, 3]))
         bound = field.bind(object())
         widget = CollectionInputWidget(bound, TestRequest())

Modified: Zope3/trunk/src/zope/app/form/browser/tests/test_choicewidget.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/tests/test_choicewidget.py	2004-09-17 16:16:12 UTC (rev 27587)
+++ Zope3/trunk/src/zope/app/form/browser/tests/test_choicewidget.py	2004-09-17 16:16:14 UTC (rev 27588)
@@ -22,23 +22,18 @@
 from zope.schema import Choice
 
 from zope.app import zapi
+from zope.app.tests import ztapi
 from zope.app.tests.placelesssetup import PlacelessSetup
 from zope.app.form.interfaces import IInputWidget, IDisplayWidget
 from zope.app.form.browser import ChoiceDisplayWidget, ChoiceInputWidget
 from zope.app.form.browser import ItemDisplayWidget, DropdownWidget
 
 
-def provideMultiView(for_, factory, providing, name='', layer="default"):
-    s = zapi.getGlobalService(zapi.servicenames.Presentation)
-    return s.provideAdapter(IBrowserRequest, factory, name, for_,
-                            providing, layer)
-
-
 class ChoiceWidgetTest(PlacelessSetup, unittest.TestCase):
 
     def test_ChoiceDisplayWidget(self):
-        provideMultiView((IChoice, IIterableVocabulary),
-                         ItemDisplayWidget, IDisplayWidget)
+        ztapi.provideMultiView((IChoice, IIterableVocabulary), IBrowserRequest,
+                               IDisplayWidget, '', ItemDisplayWidget)
         field = Choice(values=[1, 2, 3])
         bound = field.bind(object())
         widget = ChoiceDisplayWidget(bound, TestRequest())
@@ -48,8 +43,8 @@
 
 
     def test_ChoiceInputWidget(self):
-        provideMultiView((IChoice, IIterableVocabulary),
-                         DropdownWidget, IInputWidget)
+        ztapi.provideMultiView((IChoice, IIterableVocabulary), IBrowserRequest,
+                               IInputWidget, '', DropdownWidget)
         field = Choice(values=[1, 2, 3])
         bound = field.bind(object())
         widget = ChoiceInputWidget(bound, TestRequest())

Modified: Zope3/trunk/src/zope/app/form/browser/tests/test_directives.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/tests/test_directives.py	2004-09-17 16:16:12 UTC (rev 27587)
+++ Zope3/trunk/src/zope/app/form/browser/tests/test_directives.py	2004-09-17 16:16:14 UTC (rev 27588)
@@ -18,23 +18,22 @@
 import os
 import unittest
 from cStringIO import StringIO
+
 from zope.component.exceptions import ComponentLookupError
+from zope.configuration.xmlconfig import xmlconfig, XMLConfig
 from zope.exceptions import NotFoundError
 from zope.interface import Interface, implements
 from zope.publisher.browser import TestRequest
+from zope.schema import TextLine, Int
+from zope.security.proxy import ProxyFactory
 
 from zope.app import zapi
 import zope.app.component
 import zope.app.form.browser
 import zope.app.publisher.browser
-
-from zope.configuration.xmlconfig import xmlconfig, XMLConfig
-from zope.component import getDefaultViewName, getResource
+from zope.app.form.browser import TextWidget
 from zope.app.tests.placelesssetup import PlacelessSetup
-from zope.security.proxy import ProxyFactory
 
-from zope.schema import TextLine, Int
-from zope.app.form.browser import TextWidget
 
 tests_path = os.path.join(
     os.path.dirname(zope.app.publisher.browser.__file__),
@@ -88,7 +87,6 @@
 
         ztapi.provideAdapter(None, ITraversable, DefaultTraversable)
 
-        ps =  zapi.getGlobalService(zapi.servicenames.Presentation)
         
     def testAddForm(self):
         self.assertEqual(zapi.queryView(ob, 'test', request),

Modified: Zope3/trunk/src/zope/app/form/browser/tests/test_vocabularyquery.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/tests/test_vocabularyquery.py	2004-09-17 16:16:12 UTC (rev 27587)
+++ Zope3/trunk/src/zope/app/form/browser/tests/test_vocabularyquery.py	2004-09-17 16:16:14 UTC (rev 27588)
@@ -31,12 +31,6 @@
 from zope.app.form.browser.vocabularyquery import VocabularyQueryViewBase
 from zope.app.form.browser.tests import support
 
-
-def provideMultiView(for_, factory, providing, name='', layer="default"):
-    s = zapi.getGlobalService(zapi.servicenames.Presentation)
-    return s.provideAdapter(IBrowserRequest, factory, name, for_,
-                            providing, layer)
-
 _marker = object()
 
 class SampleContent(object):
@@ -170,8 +164,9 @@
         return field.bind(content)
 
     def registerViews(self):
-        provideMultiView((ISampleVocabularyQuery, IChoice),
-                         SampleQueryViewSingle, IVocabularyQueryView)
+        ztapi.provideMultiView(
+            (ISampleVocabularyQuery, IChoice), IBrowserRequest,
+            IVocabularyQueryView, '', SampleQueryViewSingle)
 
 
 class MultiSelectionQuerySupportTests(QuerySupportTestBase):
@@ -195,8 +190,9 @@
         return field.bind(content)
 
     def registerViews(self):
-        provideMultiView((ISampleVocabularyQuery, ICollection),
-                         SampleQueryViewMulti, IVocabularyQueryView)
+        ztapi.provideMultiView(
+            (ISampleVocabularyQuery, ICollection), IBrowserRequest,
+            IVocabularyQueryView, '', SampleQueryViewMulti)
 
 
 def test_suite():



More information about the Zope3-Checkins mailing list