[Zope3-checkins] CVS: Zope3/src/zope/app/browser/form/tests - test_vocabularywidget.py:1.1.2.18
Fred L. Drake, Jr.
fred@zope.com
Fri, 16 May 2003 13:35:36 -0400
Update of /cvs-repository/Zope3/src/zope/app/browser/form/tests
In directory cvs.zope.org:/tmp/cvs-serv14238
Modified Files:
Tag: schema-vocabulary-branch
test_vocabularywidget.py
Log Message:
add docstrings
=== Zope3/src/zope/app/browser/form/tests/test_vocabularywidget.py 1.1.2.17 => 1.1.2.18 ===
--- Zope3/src/zope/app/browser/form/tests/test_vocabularywidget.py:1.1.2.17 Fri May 16 12:09:39 2003
+++ Zope3/src/zope/app/browser/form/tests/test_vocabularywidget.py Fri May 16 13:35:35 2003
@@ -98,14 +98,19 @@
class QueryVocabulary(BasicVocabulary):
+ """Vocabulary that offer simple query support."""
def getQuery(self):
return MyVocabularyQuery(self)
+
class IMyVocabularyQuery(IVocabularyQuery):
"""Specialized query type."""
+
class MyVocabularyQuery:
+ """Vocabulary query object which query views can be registered for."""
+
__implements__ = IMyVocabularyQuery
def __init__(self, vocabulary):
@@ -113,6 +118,8 @@
class MyQueryViewSingle(vocabularywidget.VocabularyQueryViewBase):
+ """Single-selection vocabulary query view."""
+
__implements__ = IVocabularyQueryView
def getLabel(self):
@@ -120,6 +127,8 @@
class MyQueryViewMulti(vocabularywidget.VocabularyQueryViewBase):
+ """Multi-selection vocabulary query view."""
+
__implements__ = IVocabularyQueryView
def getLabel(self):
@@ -127,6 +136,10 @@
class VocabularyWidgetTestBase(PlacelessSetup, unittest.TestCase):
+ """Base class for all the vocabulary widget tests.
+
+ This class provides version helper methods.
+ """
def setUp(self):
PlacelessSetup.setUp(self)
@@ -139,6 +152,7 @@
# VocabularyMultiField)
def makeField(self, vocabulary, value=_marker):
+ """Create and return a bound vocabulary field."""
field = self.fieldClass(vocabulary=vocabulary, __name__="f")
content = SampleContent()
if value is self._marker:
@@ -147,6 +161,10 @@
return field.bind(content)
def makeRequest(self, querystring=None):
+ """Create and return a request.
+
+ If querystring is not None, it is passed as the QUERY_STRING.
+ """
if querystring is None:
return TestRequest()
else:
@@ -156,6 +174,7 @@
# modified from test_browserwidget.BrowserWidgetTest:
def verifyResult(self, result, check_list):
+ """Ensure that each element of check_list is present in result."""
for check in check_list:
self.assert_(result.find(check) >= 0,
"%r not found in %r" % (check, result))
@@ -167,6 +186,7 @@
def registerViews(self):
# This is equivalent to the default configuration for
# vocabulary field view registration from configure.zcml.
+ # Single-selection views only.
provideView(IVocabularyField,
"display",
IBrowserPresentation,
@@ -196,6 +216,9 @@
class MultiSelectionViews:
def registerViews(self):
+ # This is equivalent to the default configuration for
+ # vocabulary field view registration from configure.zcml.
+ # Multi-selection views only.
provideView(IVocabularyMultiField,
"display",
IBrowserPresentation,
@@ -223,6 +246,8 @@
class SelectionTestBase(VocabularyWidgetTestBase):
+ """Base class for the general widget tests (without query support)."""
+
def test_vocabulary_specialization(self):
bound = self.makeField(SampleVocabulary(["frobnication"]))
w = getView(bound, "display", self.makeRequest())
@@ -230,6 +255,7 @@
class SingleSelectionTests(SingleSelectionViews, SelectionTestBase):
+ """Test cases for basic single-selection widgets."""
defaultFieldValue = "splat"
fieldClass = vocabulary.VocabularyField
@@ -288,6 +314,7 @@
class MultiSelectionTests(MultiSelectionViews, SelectionTestBase):
+ """Test cases for basic multi-selection widgets."""
defaultFieldValue = ["splat"]
fieldClass = vocabulary.VocabularyMultiField
@@ -415,6 +442,7 @@
class SingleSelectionQuerySupportTests(SingleSelectionViews,
QuerySupportTestBase):
+ """Query support tests for single-selection widgets."""
defaultFieldValue = "splat"
fieldClass = vocabulary.VocabularyField
@@ -430,6 +458,7 @@
class MultiSelectionQuerySupportTests(MultiSelectionViews,
QuerySupportTestBase):
+ """Query support tests for multi-selection widgets."""
defaultFieldValue = ["splat"]
fieldClass = vocabulary.VocabularyMultiField