[Zope3-checkins] CVS: Zope3/src/zope/app/browser/form/tests -
test_add.py:1.21 test_editview.py:1.14
test_objectwidget.py:1.5 test_sequencewidget.py:1.5
test_vocabularywidget.py:1.26
Jim Fulton
cvs-admin at zope.org
Fri Nov 21 12:12:26 EST 2003
Update of /cvs-repository/Zope3/src/zope/app/browser/form/tests
In directory cvs.zope.org:/tmp/cvs-serv31883/src/zope/app/browser/form/tests
Modified Files:
test_add.py test_editview.py test_objectwidget.py
test_sequencewidget.py test_vocabularywidget.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/form/tests/test_add.py 1.20 => 1.21 ===
--- Zope3/src/zope/app/browser/form/tests/test_add.py:1.20 Mon Aug 4 10:52:49 2003
+++ Zope3/src/zope/app/browser/form/tests/test_add.py Fri Nov 21 12:11:56 2003
@@ -18,12 +18,12 @@
import unittest
+from zope.app.tests import ztapi
from zope.interface import Interface, implements
-from zope.publisher.interfaces.browser import IBrowserPresentation
+from zope.publisher.interfaces.browser import IBrowserRequest
from zope.publisher.browser import TestRequest
from zope.schema import TextLine, accessors
from zope.component import getView
-from zope.component.adapter import provideAdapter
from zope.app.browser.form.add import AddViewFactory, AddView
from zope.app.browser.form.metaconfigure import AddFormDirective
@@ -93,7 +93,7 @@
def setUp(self):
self._context = Context()
PlacelessSetup.setUp(self)
- provideAdapter(IFoo, IBar, FooBarAdapter)
+ ztapi.provideAdapter(IFoo, IBar, FooBarAdapter)
def _invoke_add(self, schema=I, name="addthis", permission="zope.Public",
label="Add this", content_factory=C, class_=V,
@@ -143,7 +143,7 @@
(descriminator, callable, args, kw) = self._context.last_action
self.assertEqual(descriminator,
- ('view', IAdding, "addthis", IBrowserPresentation,
+ ('view', IAdding, "addthis", IBrowserRequest,
"default"))
self.assertEqual(callable, AddViewFactory)
=== Zope3/src/zope/app/browser/form/tests/test_editview.py 1.13 => 1.14 ===
--- Zope3/src/zope/app/browser/form/tests/test_editview.py:1.13 Wed Aug 13 17:28:04 2003
+++ Zope3/src/zope/app/browser/form/tests/test_editview.py Fri Nov 21 12:11:56 2003
@@ -15,16 +15,15 @@
"""
import unittest
+from zope.app.tests import ztapi
from zope.app.tests.placelesssetup import PlacelessSetup
from zope.app.event.tests.placelesssetup import getEvents
from zope.interface import Interface, implements
from zope.schema import TextLine, accessors
from zope.schema.interfaces import ITextLine
from zope.publisher.browser import TestRequest
-from zope.publisher.interfaces.browser import IBrowserPresentation
from zope.app.browser.form.editview import EditView
-from zope.component.view import provideView, setDefaultViewName
-from zope.component.adapter import provideAdapter
+from zope.app.tests import ztapi
from zope.app.browser.form.widget import TextWidget
from zope.app.browser.form.submit import Update
from zope.component.exceptions import ComponentLookupError
@@ -81,9 +80,9 @@
def setUp(self):
PlacelessSetup.setUp(self)
- provideView(ITextLine, 'edit', IBrowserPresentation, TextWidget)
- setDefaultViewName(ITextLine, IBrowserPresentation, "edit")
- provideAdapter(IFoo, IBar, FooBarAdapter)
+ ztapi.browserView(ITextLine, 'edit', TextWidget)
+ ztapi.setDefaultViewName(ITextLine, "edit")
+ ztapi.provideAdapter(IFoo, IBar, FooBarAdapter)
def test_setPrefix_and_widgets(self):
v = EV(C(), TestRequest())
=== Zope3/src/zope/app/browser/form/tests/test_objectwidget.py 1.4 => 1.5 ===
--- Zope3/src/zope/app/browser/form/tests/test_objectwidget.py:1.4 Wed Aug 13 17:28:04 2003
+++ Zope3/src/zope/app/browser/form/tests/test_objectwidget.py Fri Nov 21 12:11:56 2003
@@ -17,10 +17,9 @@
import unittest
+from zope.app.tests import ztapi
from zope.interface import Interface, implements
-from zope.component.view import provideView
from zope.schema.interfaces import ITextLine
-from zope.publisher.interfaces.browser import IBrowserPresentation
from zope.publisher.browser import TestRequest
from zope.schema import Object, TextLine
from zope.app.browser.form.widget import TextWidget, ObjectWidget
@@ -40,7 +39,7 @@
return ObjectWidget(context, request, **kw)
def setUpContent(self, desc=u''):
- provideView(ITextLine, 'edit', IBrowserPresentation, [TextWidget])
+ ztapi.browserView(ITextLine, 'edit', TextWidget)
class ITestContent(Interface):
foo = self._FieldFactory(
@@ -68,7 +67,7 @@
def setUp(self):
BrowserWidgetTest.setUp(self)
self.field = Object(ITestContact, __name__=u'foo')
- provideView(ITextLine, 'edit', IBrowserPresentation, [TextWidget])
+ ztapi.browserView(ITextLine, 'edit', [TextWidget])
def test_applyChanges(self):
self.request.form['field.foo.name'] = u'Foo Name'
=== Zope3/src/zope/app/browser/form/tests/test_sequencewidget.py 1.4 => 1.5 ===
--- Zope3/src/zope/app/browser/form/tests/test_sequencewidget.py:1.4 Wed Aug 13 17:28:04 2003
+++ Zope3/src/zope/app/browser/form/tests/test_sequencewidget.py Fri Nov 21 12:11:56 2003
@@ -17,10 +17,9 @@
import unittest
-from zope.component.view import provideView
+from zope.app.tests import ztapi
from zope.app.browser.form.widget import TextWidget
from zope.schema.interfaces import ITextLine, ValidationError
-from zope.publisher.interfaces.browser import IBrowserPresentation
from zope.publisher.browser import TestRequest
from zope.schema import Tuple, List, TextLine
from zope.app.browser.form.widget import TupleSequenceWidget, \
@@ -42,7 +41,7 @@
BrowserWidgetTest.setUp(self)
self.field = Tuple(__name__=u'foo',
value_type=TextLine(__name__=u'bar'))
- provideView(ITextLine, 'edit', IBrowserPresentation, [TextWidget])
+ ztapi.browserView(ITextLine, 'edit', TextWidget)
def test_haveNoData(self):
self.failIf(self._widget.hasInput())
=== Zope3/src/zope/app/browser/form/tests/test_vocabularywidget.py 1.25 => 1.26 ===
--- Zope3/src/zope/app/browser/form/tests/test_vocabularywidget.py:1.25 Mon Sep 29 16:13:13 2003
+++ Zope3/src/zope/app/browser/form/tests/test_vocabularywidget.py Fri Nov 21 12:11:56 2003
@@ -16,16 +16,15 @@
import unittest
+from zope.app.tests import ztapi
from zope.app.browser.form import vocabularywidget
from zope.app.browser.form.tests import support
from zope.app.interfaces.browser.form import IBrowserWidget
from zope.app.interfaces.browser.form import IVocabularyQueryView
from zope.app.tests.placelesssetup import PlacelessSetup
from zope.component import getView
-from zope.component.view import provideView
from zope.interface.declarations import implements
from zope.publisher.browser import TestRequest
-from zope.publisher.interfaces.browser import IBrowserPresentation
from zope.schema.interfaces import IVocabulary, IVocabularyQuery
from zope.schema.interfaces import IVocabularyField, IVocabularyListField
@@ -151,36 +150,35 @@
# This is equivalent to the default configuration for
# vocabulary field view registration from configure.zcml.
# Single-selection views only.
- provideView(IVocabularyField,
- "display",
- IBrowserPresentation,
- vocabularywidget.VocabularyFieldDisplayWidget)
- provideView(IVocabularyField,
- "edit",
- IBrowserPresentation,
- vocabularywidget.VocabularyFieldEditWidget)
+ ztapi.browserView(
+ IVocabularyField,
+ "display",
+ vocabularywidget.VocabularyFieldDisplayWidget)
+ ztapi.browserView(
+ IVocabularyField,
+ "edit",
+ vocabularywidget.VocabularyFieldEditWidget)
# Register the "basic" widgets:
- provideView(IVocabularyTokenized,
- "field-display-widget",
- IBrowserPresentation,
- vocabularywidget.VocabularyDisplayWidget)
- provideView(IVocabularyTokenized,
- "field-edit-widget",
- IBrowserPresentation,
- # XXX indirect through a derived class to allow
- # testing of multiple concrete widgets
- self.singleSelectionEditWidget)
- provideView(IIterableVocabularyQuery,
- "widget-query-helper",
- IBrowserPresentation,
- vocabularywidget.IterableVocabularyQueryView)
+ ztapi.browserView(
+ IVocabularyTokenized,
+ "field-display-widget",
+ vocabularywidget.VocabularyDisplayWidget)
+ ztapi.browserView(
+ IVocabularyTokenized,
+ "field-edit-widget",
+ # XXX indirect through a derived class to allow
+ # testing of multiple concrete widgets
+ self.singleSelectionEditWidget)
+ ztapi.browserView(
+ IIterableVocabularyQuery,
+ "widget-query-helper",
+ vocabularywidget.IterableVocabularyQueryView)
# The following widget registration supports the specific
# sample vocabulary we're using, used to demonstrate how to
# override widget selection based on vocabulary:
- provideView(ISampleVocabulary,
+ ztapi.browserView(ISampleVocabulary,
"field-display-widget",
- IBrowserPresentation,
- SampleDisplayWidget)
+ SampleDisplayWidget)
class MultiSelectionViews:
@@ -189,34 +187,33 @@
# This is equivalent to the default configuration for
# vocabulary field view registration from configure.zcml.
# Multi-selection views only.
- provideView(IVocabularyListField,
- "display",
- IBrowserPresentation,
- vocabularywidget.VocabularyListFieldDisplayWidget)
- provideView(IVocabularyListField,
- "edit",
- IBrowserPresentation,
- vocabularywidget.VocabularyListFieldEditWidget)
+ ztapi.browserView(
+ IVocabularyListField,
+ "display",
+ vocabularywidget.VocabularyListFieldDisplayWidget)
+ ztapi.browserView(
+ IVocabularyListField,
+ "edit",
+ vocabularywidget.VocabularyListFieldEditWidget)
# Bind widgets to the vocabulary fields:
- provideView(IVocabularyTokenized,
- "field-display-list-widget",
- IBrowserPresentation,
- vocabularywidget.VocabularyListDisplayWidget)
- provideView(IVocabularyTokenized,
- "field-edit-list-widget",
- IBrowserPresentation,
- vocabularywidget.VocabularyMultiEditWidget)
- provideView(IIterableVocabularyQuery,
- "widget-query-list-helper",
- IBrowserPresentation,
- vocabularywidget.IterableVocabularyQueryMultiView)
+ ztapi.browserView(
+ IVocabularyTokenized,
+ "field-display-list-widget",
+ vocabularywidget.VocabularyListDisplayWidget)
+ ztapi.browserView(
+ IVocabularyTokenized,
+ "field-edit-list-widget",
+ vocabularywidget.VocabularyMultiEditWidget)
+ ztapi.browserView(
+ IIterableVocabularyQuery,
+ "widget-query-list-helper",
+ vocabularywidget.IterableVocabularyQueryMultiView)
# The following widget registration supports the specific
# sample vocabulary we're using, used to demonstrate how to
# override widget selection based on vocabulary:
- provideView(ISampleVocabulary,
+ ztapi.browserView(ISampleVocabulary,
"field-display-list-widget",
- IBrowserPresentation,
- SampleDisplayWidget)
+ SampleDisplayWidget)
class SelectionTestBase(VocabularyWidgetTestBase):
@@ -502,10 +499,9 @@
def registerViews(self):
SingleSelectionViews.registerViews(self)
- provideView(IMyVocabularyQuery,
- "widget-query-helper",
- IBrowserPresentation,
- MyQueryViewSingle)
+ ztapi.browserView(IMyVocabularyQuery,
+ "widget-query-helper",
+ MyQueryViewSingle)
class MultiSelectionQuerySupportTests(MultiSelectionViews,
@@ -518,10 +514,9 @@
def registerViews(self):
MultiSelectionViews.registerViews(self)
- provideView(IMyVocabularyQuery,
- "widget-query-list-helper",
- IBrowserPresentation,
- MyQueryViewMulti)
+ ztapi.browserView(IMyVocabularyQuery,
+ "widget-query-list-helper",
+ MyQueryViewMulti)
def test_suite():
More information about the Zope3-Checkins
mailing list