[Zope3-checkins]
CVS: Zope3/src/zope/app/browser/form/complexsample/tests
- test_widget.py:1.7.22.1
Garrett Smith
garrett at mojave-corp.com
Thu Feb 26 00:11:20 EST 2004
Update of /cvs-repository/Zope3/src/zope/app/browser/form/complexsample/tests
In directory cvs.zope.org:/tmp/cvs-serv25181/src/zope/app/browser/form/complexsample/tests
Modified Files:
Tag: garrett-widgets2-branch
test_widget.py
Log Message:
Yet another branch for widgets refactoring (YABFWR).
=== Zope3/src/zope/app/browser/form/complexsample/tests/test_widget.py 1.7 => 1.7.22.1 ===
--- Zope3/src/zope/app/browser/form/complexsample/tests/test_widget.py:1.7 Thu Nov 27 08:59:12 2003
+++ Zope3/src/zope/app/browser/form/complexsample/tests/test_widget.py Thu Feb 26 00:10:49 2004
@@ -16,12 +16,13 @@
import unittest
+from zope.app import zapi
from zope.app.tests import ztapi
from zope.app.browser.form.tests import support
from zope.app.browser.form import vocabularywidget
from zope.app.interfaces.form import WidgetInputError
+from zope.app.interfaces.form import IEditWidget, IDisplayWidget
from zope.app.tests.placelesssetup import PlacelessSetup
-from zope.component import getView
from zope.interface.declarations import \
directlyProvides, providedBy, implements
from zope.publisher.browser import TestRequest
@@ -128,37 +129,37 @@
def setUp(self):
super(TestBase, self).setUp()
# display
- ztapi.browserView(
+ ztapi.browserViewProviding(
IVocabularyUniqueListField,
- "display",
- vocabularywidget.VocabularyUniqueListFieldDisplayWidget)
- ztapi.browserView(
+ vocabularywidget.VocabularyUniqueListFieldDisplayWidget,
+ IDisplayWidget)
+ ztapi.browserViewProviding(
ISampleVocabulary,
- "field-display-unique-list-widget",
- complexsample.SampleListDisplay)
+ complexsample.SampleListDisplay,
+ vocabularywidget.IVocabularyListDisplayWidget)
# edit
- ztapi.browserView(
+ ztapi.browserViewProviding(
IVocabularyUniqueListField,
- "edit",
- vocabularywidget.VocabularyUniqueListFieldEditWidget)
- ztapi.browserView(
+ vocabularywidget.VocabularyUniqueListFieldEditWidget,
+ IEditWidget)
+ ztapi.browserViewProviding(
ISampleVocabulary,
- "field-edit-unique-list-widget",
- complexsample.SampleUniqueListEdit)
+ complexsample.SampleUniqueListEdit,
+ vocabularywidget.IVocabularyMultiEditWidget)
# query support (edit only)
- ztapi.browserView(
+ ztapi.browserViewProviding(
IFancySampleVocabularyQuery,
- "widget-query-unique-list-helper",
- complexsample.FancySampleUniqueListQueryView)
- ztapi.browserView(
+ complexsample.FancySampleUniqueListQueryView,
+ vocabularywidget.IWidgetQueryListHelper)
+ ztapi.browserViewProviding(
ISampleVocabularyQuery,
- "widget-query-unique-list-helper",
- complexsample.SampleUniqueListQueryView)
+ complexsample.SampleUniqueListQueryView,
+ vocabularywidget.IWidgetQueryListHelper)
def createWidget(self, **kw):
request = TestRequest(**kw)
request.processInputs()
- return getView(self.bound, self.viewName, request)
+ return zapi.getViewProviding(self.bound, self.viewType, request)
class SampleListTestBase(TestBase):
@@ -226,13 +227,13 @@
class SampleListDisplayTests(SampleListTestBase):
topElementName = 'ol'
- viewName = 'display'
+ viewType = IDisplayWidget
class SampleListEditTests(SampleListTestBase):
topElementName = 'div'
- viewName = 'edit'
+ viewType = IEditWidget
def test_vocab_query(self):
# trivial test to make sure the sample vocabulary is working
@@ -840,7 +841,7 @@
class SampleListQueryTests(TestBase):
- viewName = "edit"
+ viewType = IEditWidget
def setUp(self):
TestBase.setUp(self)
@@ -906,46 +907,46 @@
self.bound = self.unbound.bind(object())
# register the single-selection widgets
# display
- ztapi.browserView(
+ ztapi.browserViewProviding(
IVocabularyField,
- "display",
- vocabularywidget.VocabularyFieldDisplayWidget)
- ztapi.browserView(
+ vocabularywidget.VocabularyFieldDisplayWidget,
+ IDisplayWidget)
+ ztapi.browserViewProviding(
ISampleVocabulary,
- "field-display-widget",
- complexsample.SampleDisplay)
+ complexsample.SampleDisplay,
+ vocabularywidget.IVocabularyDisplayWidget)
# edit
- ztapi.browserView(
+ ztapi.browserViewProviding(
IVocabularyField,
- "edit",
- vocabularywidget.VocabularyFieldEditWidget)
- ztapi.browserView(
+ vocabularywidget.VocabularyFieldEditWidget,
+ IEditWidget)
+ ztapi.browserViewProviding(
ISampleVocabulary,
- "field-edit-widget",
- complexsample.SampleEdit)
+ complexsample.SampleEdit,
+ vocabularywidget.IVocabularyEditWidget)
# query support (edit only) --
- ztapi.browserView(
+ ztapi.browserViewProviding(
IFancySampleVocabularyQuery,
- "widget-query-helper",
- complexsample.FancySampleQueryView)
- ztapi.browserView(
+ complexsample.FancySampleQueryView,
+ vocabularywidget.IWidgetQueryHelper)
+ ztapi.browserViewProviding(
ISampleVocabularyQuery,
- "widget-query-helper",
- complexsample.SampleQueryView)
+ complexsample.SampleQueryView,
+ vocabularywidget.IWidgetQueryHelper)
def test_display_empty(self):
- self.viewName = "display"
+ self.viewType = IDisplayWidget
w = self.createWidget()
self.verifyResult(w(), ["no value"])
def test_display_with_form_data(self):
- self.viewName = "display"
+ self.viewType = IDisplayWidget
w = self.createWidget(QUERY_STRING=("field.path-marker=x"
"&field.path=/a/path"))
self.verifyResult(w(), ["/a/path"])
def test_display_with_bad_form_data(self):
- self.viewName = "display"
+ self.viewType = IDisplayWidget
w = self.createWidget(QUERY_STRING=("field.path-marker=x"
"&field.path=/invalid/path"))
self.verifyResult(w(), [
@@ -955,7 +956,7 @@
])
def test_edit_without_form_data(self):
- self.viewName = "edit"
+ self.viewType = IEditWidget
w = self.createWidget()
self.assert_(not w.hasInput())
self.verifyResult(w(), [
@@ -965,7 +966,7 @@
])
def test_edit_with_empty_form_data(self):
- self.viewName = "edit"
+ self.viewType = IEditWidget
w = self.createWidget(QUERY_STRING="field.path-marker=x")
self.verifyResult(w(), [
"no value",
@@ -974,7 +975,7 @@
])
def test_edit_select_clears_query(self):
- self.viewName = "edit"
+ self.viewType = IEditWidget
w = self.createWidget(QUERY_STRING=("field.path-marker=x"
"&field.path-query.action-select=x"
"&field.path-query.picks=/a/path"
@@ -992,7 +993,7 @@
])
def test_edit_dismiss_clears_query(self):
- self.viewName = "edit"
+ self.viewType = IEditWidget
w = self.createWidget(
QUERY_STRING=("field.path-marker=x"
"&field.path=/b/path"
@@ -1012,7 +1013,7 @@
])
def test_edit_clear_removes_value(self):
- self.viewName = "edit"
+ self.viewType = IEditWidget
w = self.createWidget(QUERY_STRING=("field.path-marker=x"
"&field.path.action-clear=x"
"&field.path=/a/path"))
@@ -1025,7 +1026,7 @@
])
def test_edit_with_form_data(self):
- self.viewName = "edit"
+ self.viewType = IEditWidget
w = self.createWidget(QUERY_STRING=("field.path-marker=x"
"&field.path=/a/path"))
r = w()
@@ -1057,7 +1058,7 @@
], inorder=True)
def test_edit_with_query(self):
- self.viewName = "edit"
+ self.viewType = IEditWidget
w = self.createWidget(QUERY_STRING=("field.path-marker=x"
"&field.path=/a/path"
"&field.path-query.start=0"
More information about the Zope3-Checkins
mailing list