Commits

Ralph Bean committed 6eb6b8c

Test Suite.

  • Participants
  • Parent commits 21f7d14

Comments (0)

Files changed (2)

 from setuptools import setup, find_packages
 
+# Odd hack to get tests running smoothly on py2.7
+try:
+    import multiprocessing
+    import logging
+except ImportError, e:
+    pass
+
 setup(
     name='tw2.jqplugins.chosen',
     version='0.1',
     namespace_packages = ['tw2'],
     zip_safe=False,
     include_package_data=True,
+    tests_require = [
+        'nose',
+        'BeautifulSoup',
+        'FormEncode',
+        'WebTest',
+        'strainer',
+    ],
     test_suite = 'nose.collector',
     entry_points="""
         [tw2.widgets]

File tests/test_widget.py

 from tw2.core.testbase import WidgetTest
-from tw2.jqplugins.chosen import *
+from tw2.jqplugins.chosen.widgets import (
+    ChosenSingleSelectField,
+    ChosenMultipleSelectField,
+)
 
-class ChosenMixin(WidgetTest):
+
+class TestChosenSingleSelectField(WidgetTest):
+    engines = ['mako', 'genshi']
     # place your widget at the TestWidget attribute
-    widget = ChosenMixin
-    # Initialization args. go here 
-    attrs = {'id':'chosen-test'}
+    widget = ChosenSingleSelectField
+    # Initialization args. go here
+    attrs = {'id': 'chosen-test', 'options': ['Red', 'Blue']}
     params = {}
-    expected = """<div id="chosen-test"></div>"""
+    expected = """
+    <select id="chosen-test" name="chosen-test">
+            <option></option><option value="Red">Red</option><option
+            value="Blue">Blue</option>
+            </select>"""
+
+
+class TestChosenMultipleSelectField(WidgetTest):
+    engines = ['mako', 'genshi']
+    # place your widget at the TestWidget attribute
+    widget = ChosenMultipleSelectField
+    # Initialization args. go here
+    attrs = {'id': 'chosen-test', 'options': ['Red', 'Blue']}
+    params = {}
+    expected = """
+    <select multiple="multiple" id="chosen-test" name="chosen-test">
+            <option value="Red">Red</option><option
+            value="Blue">Blue</option>
+            </select>"""