[Zope3-checkins] CVS: Zope3/src/zope/app/browser/form/tests - test_vocabularywidget.py:1.1.2.19

Fred L. Drake, Jr. fred@zope.com
Fri, 16 May 2003 16:13:21 -0400


Update of /cvs-repository/Zope3/src/zope/app/browser/form/tests
In directory cvs.zope.org:/tmp/cvs-serv7149

Modified Files:
      Tag: schema-vocabulary-branch
	test_vocabularywidget.py 
Log Message:
- added test that makes sure the query-input section is glued in
  properly when there's a query
- various updates to reflect changes in the generated HTML fragments


=== Zope3/src/zope/app/browser/form/tests/test_vocabularywidget.py 1.1.2.18 => 1.1.2.19 ===
--- Zope3/src/zope/app/browser/form/tests/test_vocabularywidget.py:1.1.2.18	Fri May 16 13:35:35 2003
+++ Zope3/src/zope/app/browser/form/tests/test_vocabularywidget.py	Fri May 16 16:13:20 2003
@@ -117,7 +117,14 @@
         self.vocabulary = vocabulary
 
 
-class MyQueryViewSingle(vocabularywidget.VocabularyQueryViewBase):
+class MyQueryViewBase(vocabularywidget.VocabularyQueryViewBase):
+    """Base class for test query views."""
+
+    def renderQueryInput(self):
+        return "this-is-query-input"
+
+
+class MyQueryViewSingle(MyQueryViewBase):
     """Single-selection vocabulary query view."""
 
     __implements__ = IVocabularyQueryView
@@ -126,7 +133,7 @@
         return "single"
 
 
-class MyQueryViewMulti(vocabularywidget.VocabularyQueryViewBase):
+class MyQueryViewMulti(MyQueryViewBase):
     """Multi-selection vocabulary query view."""
 
     __implements__ = IVocabularyQueryView
@@ -280,7 +287,6 @@
             'selected="selected"',
             'id="field.f"',
             'name="field.f"',
-            'class="vocabularyType"',
             'value="splat"',
             '>splat<',
             'value="foobar"',
@@ -328,7 +334,6 @@
             '<span',
             'id="field.f"',
             'name="field.f"',
-            'class="vocabularyType"',
             '</span>',
             ])
 
@@ -341,7 +346,6 @@
             '<ol',
             'id="field.f"',
             'name="field.f"',
-            'class="vocabularyType"',
             '</ol>',
             ])
         w.cssClass = 'test'
@@ -365,7 +369,6 @@
             '<ol',
             'id="field.f"',
             'name="field.f"',
-            'class="vocabularyType"',
             '<li',
             '>splat<',
             '</li>',
@@ -381,7 +384,6 @@
         self.verifyResult(w(), [
             'id="field.f"',
             'name="field.f:list"',
-            'class="vocabularyType"',
             'value="splat"',
             '>splat<',
             'value="foobar"',
@@ -433,11 +435,24 @@
     mechanics.
     """
 
+    queryableVocabulary = QueryVocabulary(["splat", "foobar", "frob"])
+
     def test_get_query_helper(self):
-        bound = self.makeField(QueryVocabulary(["splat", "foobar", "frob"]))
+        bound = self.makeField(self.queryableVocabulary)
         request = self.makeRequest()
         w = getView(bound, "edit", request)
+        self.assert_(isinstance(w.query, MyVocabularyQuery))
+        self.assertEqual(w.queryview.name, w.name + "-query")
         self.assertEqual(w.queryview.getLabel(), self.queryViewLabel)
+
+    def test_query_section(self):
+        bound = self.makeField(self.queryableVocabulary)
+        w = getView(bound, "edit", self.makeRequest())
+        checks = [
+            "this-is-query-input",
+            ]
+        self.verifyResult(w.queryview.renderInput(), checks)
+        self.verifyResult(w(), checks + ['class="queryinput"'])
 
 
 class SingleSelectionQuerySupportTests(SingleSelectionViews,