[Zope3-checkins] CVS: Zope3/src/zope/app/browser/form/tests - test_vocabularywidget.py:1.7
Fred L. Drake, Jr.
fred@zope.com
Thu, 29 May 2003 11:39:22 -0400
Update of /cvs-repository/Zope3/src/zope/app/browser/form/tests
In directory cvs.zope.org:/tmp/cvs-serv4766
Modified Files:
test_vocabularywidget.py
Log Message:
Test both single-selection edit widgets.
=== Zope3/src/zope/app/browser/form/tests/test_vocabularywidget.py 1.6 => 1.7 ===
--- Zope3/src/zope/app/browser/form/tests/test_vocabularywidget.py:1.6 Wed May 28 13:17:57 2003
+++ Zope3/src/zope/app/browser/form/tests/test_vocabularywidget.py Thu May 29 11:39:20 2003
@@ -231,7 +231,9 @@
provideView(IVocabularyTokenized,
"field-edit-widget",
IBrowserPresentation,
- vocabularywidget.VocabularyEditWidget)
+ # XXX indirect through a derived class to allow
+ # testing of multiple concrete widgets
+ self.singleSelectionEditWidget)
provideView(IIterableVocabularyQuery,
"widget-query-helper",
IBrowserPresentation,
@@ -290,7 +292,7 @@
self.assertEqual(w(), "foo")
-class SingleSelectionTests(SingleSelectionViews, SelectionTestBase):
+class SingleSelectionTestsBase(SingleSelectionViews, SelectionTestBase):
"""Test cases for basic single-selection widgets."""
defaultFieldValue = "splat"
@@ -308,7 +310,7 @@
self.assert_(w.haveData())
self.assertEqual(w(), "foobar")
- def test_edit(self):
+ def test_edit(self, extraChecks=[]):
bound = self.makeField(BasicVocabulary(["splat", "foobar"]))
w = getView(bound, "edit", self.makeRequest())
self.assert_(not w.haveData())
@@ -320,7 +322,7 @@
'>splat<',
'value="foobar"',
'>foobar<',
- ])
+ ] + extraChecks)
s1, s2 = w.renderItems("foobar")
self.verifyResult(s1, [
'value="splat"',
@@ -347,6 +349,20 @@
'value="foobar"',
])
+class SingleSelectionTests(SingleSelectionTestsBase):
+ """Test single-selection with the selection-box widget."""
+
+ singleSelectionEditWidget = vocabularywidget.SelectListWidget
+
+
+class DropdownSelectionTests(SingleSelectionTestsBase):
+ """Test single-selection with the dropdown-list widget."""
+
+ singleSelectionEditWidget = vocabularywidget.DropdownListWidget
+
+ def test_edit(self):
+ SingleSelectionTestsBase.test_edit(self, extraChecks=['size="1"'])
+
class MultiSelectionTests(MultiSelectionViews, SelectionTestBase):
"""Test cases for basic multi-selection widgets."""
@@ -509,6 +525,7 @@
defaultFieldValue = "splat"
fieldClass = vocabulary.VocabularyField
queryViewLabel = "single"
+ singleSelectionEditWidget = vocabularywidget.VocabularyEditWidget
def registerViews(self):
SingleSelectionViews.registerViews(self)
@@ -536,6 +553,7 @@
def test_suite():
suite = unittest.makeSuite(SingleSelectionTests)
+ suite.addTest(unittest.makeSuite(DropdownSelectionTests))
suite.addTest(unittest.makeSuite(MultiSelectionTests))
suite.addTest(unittest.makeSuite(SingleSelectionQuerySupportTests))
suite.addTest(unittest.makeSuite(MultiSelectionQuerySupportTests))