[Zope3-checkins] CVS: Zope3/src/zope/app/browser/form/tests - test_vocabularywidget.py:1.1.2.20
Fred L. Drake, Jr.
fred@zope.com
Fri, 16 May 2003 16:35:57 -0400
Update of /cvs-repository/Zope3/src/zope/app/browser/form/tests
In directory cvs.zope.org:/tmp/cvs-serv12810
Modified Files:
Tag: schema-vocabulary-branch
test_vocabularywidget.py
Log Message:
- add tests for the query output control
=== Zope3/src/zope/app/browser/form/tests/test_vocabularywidget.py 1.1.2.19 => 1.1.2.20 ===
--- Zope3/src/zope/app/browser/form/tests/test_vocabularywidget.py:1.1.2.19 Fri May 16 16:13:20 2003
+++ Zope3/src/zope/app/browser/form/tests/test_vocabularywidget.py Fri May 16 16:35:57 2003
@@ -120,9 +120,15 @@
class MyQueryViewBase(vocabularywidget.VocabularyQueryViewBase):
"""Base class for test query views."""
+ def getResults(self):
+ return self.request.form.get(self.name)
+
def renderQueryInput(self):
return "this-is-query-input"
+ def renderQueryResults(self, results):
+ return "query-results-go-here"
+
class MyQueryViewSingle(MyQueryViewBase):
"""Single-selection vocabulary query view."""
@@ -186,6 +192,12 @@
self.assert_(result.find(check) >= 0,
"%r not found in %r" % (check, result))
+ def verifyResultMissing(self, result, check_list):
+ """Ensure that each element of check_list is omitted from result."""
+ for check in check_list:
+ self.assert_(result.find(check) < 0,
+ "%r unexpectedly found in %r" % (check, result))
+
class SingleSelectionViews:
"""Mixin that registers single-selection views."""
@@ -445,7 +457,7 @@
self.assertEqual(w.queryview.name, w.name + "-query")
self.assertEqual(w.queryview.getLabel(), self.queryViewLabel)
- def test_query_section(self):
+ def test_query_input_section(self):
bound = self.makeField(self.queryableVocabulary)
w = getView(bound, "edit", self.makeRequest())
checks = [
@@ -453,6 +465,24 @@
]
self.verifyResult(w.queryview.renderInput(), checks)
self.verifyResult(w(), checks + ['class="queryinput"'])
+
+ def test_query_output_section_without_results(self):
+ bound = self.makeField(self.queryableVocabulary)
+ w = getView(bound, "edit", self.makeRequest())
+ checks = [
+ "query-results-go-here",
+ ]
+ self.verifyResultMissing(w.queryview.renderResults(), checks)
+ self.verifyResultMissing(w(), checks + ['class="queryresults"'])
+
+ def test_query_output_section_with_results(self):
+ bound = self.makeField(self.queryableVocabulary)
+ w = getView(bound, "edit", self.makeRequest("field.f-query=foo"))
+ checks = [
+ "query-results-go-here",
+ ]
+ self.verifyResult(w.queryview.renderResults(), checks)
+ self.verifyResult(w(), checks + ['class="queryresults"'])
class SingleSelectionQuerySupportTests(SingleSelectionViews,